0
我想要3个具有相等边距的圆形按钮。我尝试以编程方式进行设置,但由于未绘制视图,因此我得到了NPE。在LinearLayout中放置3个圆以占用相等的空间量
如何在布局文件中执行此操作?我在下面尝试,但不是圈子。
Place 3 buttons in a LinearLayout to occupy equal amount of space
请帮忙。
我想要3个具有相等边距的圆形按钮。我尝试以编程方式进行设置,但由于未绘制视图,因此我得到了NPE。在LinearLayout中放置3个圆以占用相等的空间量
如何在布局文件中执行此操作?我在下面尝试,但不是圈子。
Place 3 buttons in a LinearLayout to occupy equal amount of space
请帮忙。
你可以试试这个。
circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="10dip"/>
<stroke android:color="#FF0000" android:width="5dip"/>
<solid android:color="#FF0000"/>
</shape>
将这个提拉文件夹并将其设置为你的按钮(在链接的接受的答案添加等)的背景。
希望这有助于
使用这样
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
</LinearLayout>
将样式到您的按钮
http://stackoverflow.com/questions/17823582/circular-buttons-in-linearlayoutvertical有为我回答 – GJain