我坚持生成上述类型的自定义可绘制对象。我能够制作圆形选择器按钮,因为它以红色和绿色边框显示。但是我无法制作包含这两个灰色和深灰色边框的按钮的其他可绘制对象。而且我也不明白如何将圆形按钮放置在正确的位置。
问问题
97 次
1 回答
1
您可以尝试这样做,这将为您提供所需的结果。
<?xml version="1.0" encoding="utf-8"?>
<!-- THE VIEW THAT HOLD THE BACKGROUND -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/temp"
android:orientation="horizontal">
<!--TAKES UP 50%-->
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Left" />
</FrameLayout>
<!-- The width of this view should be the width of the center portion(excluding the cirlces)-->
<!-- I have taken 60 after measuring.-->
<View
android:layout_width="60dp"
android:layout_height="match_parent" />
<!--TAKES UP 50%-->
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Right" />
</FrameLayout>
</LinearLayout>
我所做的很简单。将您的图像放在背景中,将区域分成两部分,使用权重。
P:S Temp 是背景文件。
结果 :
于 2015-09-30T07:22:20.500 回答