Android 在线性布局中放置3个圆以占据相等的空间
我想有3个圆形按钮水平等边距。我尝试以编程方式设置,但由于未绘制视图,所以得到了NPE 如何在布局文件中执行此操作?我在下面试过,但不是圆 请帮忙。你可以试试这个 circle.xmlAndroid 在线性布局中放置3个圆以占据相等的空间,android,android-layout,Android,Android Layout,我想有3个圆形按钮水平等边距。我尝试以编程方式设置,但由于未绘制视图,所以得到了NPE 如何在布局文件中执行此操作?我在下面试过,但不是圆 请帮忙。你可以试试这个 circle.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <corne
<?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>
将其放入drawable文件夹中,并将其设置为按钮的背景(如在链接的接受答案中添加)
希望这有助于像这样使用
<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>
将样式应用于您的按钮为我找到了答案