我的布局有RadioGroup和radiobuttons。它有效,但显示有问题。我已经分享了下面的截图。
Android 4.2.1 - 4.65英寸
平板电脑Android 2.2 - 7英寸
Android 4.1.2 - 5.5英寸
代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:padding="3dp" android:gravity="center"
android:background="@drawable/bottom"
>
<RadioGroup
android:id="@+id/radioTur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:measureWithLargestChild="true"
android:layout_gravity="center_vertical"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rad_anasayfa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:button="@null"
android:gravity="center"
android:drawableTop="@drawable/anasayfabutton"
android:textColor="@color/White"
android:onClick="Anasayfa_TIKLA"
android:text="Anasayfa" >
</RadioButton>
<RadioButton
android:id="@+id/rad_haber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/haberlerbutton"
android:textColor="@color/White"
android:onClick="Haber_TIKLA"
android:text="Haberler" >
</RadioButton>
<RadioButton
android:id="@+id/rad_duyuru"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/duyurubutton"
android:textColor="@color/White"
android:onClick="Duyuru_TIKLA"
android:text="Duyurular" >
</RadioButton>
<RadioButton
android:id="@+id/rad_yemek"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/yemekbutton"
android:textColor="@color/White"
android:onClick="Yemek_TIKLA"
android:text="Yemek" >
</RadioButton>
<RadioButton
android:id="@+id/rad_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:onClick="Arama_TIKLA"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/search_icon"
android:textColor="@color/White"
android:text="Arama" >
</RadioButton>
</RadioGroup>
</LinearLayout>
来自主要布局的代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/AnaLayout"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<include
android:id="@+id/cell1"
android:layout_height="wrap_content"
layout="@layout/bottombar"
/>
</LinearLayout>
</RelativeLayout>
我已经工作了几天。我不明白问题。有人能帮助我吗?
我的图标
答案 0 :(得分:3)
我发现了问题。问题是android:button =“@ null”。
如果radiobutton有android:button =“@ null”属性; 结果:
如果radiobutton没有android:button =“@ null”属性; 结果:
如果radiobutton有android:button =“@ null”和android:background =“@ android:color / transparent”属性 结果:
我添加了android:background =“@ android:color / transparent”所有的radiobutton并且问题解决了。
答案 1 :(得分:0)
试试这个..
将RadioGroup
宽度更改为match_parent
并尝试。
<RadioGroup
android:id="@+id/radioTur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:measureWithLargestChild="true"
android:layout_gravity="center_vertical"
android:orientation="horizontal" >
和
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<include
android:id="@+id/cell1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/bottombar"
/>
</LinearLayout>
这是我的完整代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="3dp" >
<RadioGroup
android:id="@+id/radioTur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:measureWithLargestChild="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rad_anasayfa"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Anasayfa_TIKLA"
android:text="Anasayfa"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_haber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Haber_TIKLA"
android:text="Haberler"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_duyuru"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Duyuru_TIKLA"
android:text="Duyurular"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_yemek"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Yemek_TIKLA"
android:text="Yemek"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Arama_TIKLA"
android:text="Arama"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
</RadioGroup>
</LinearLayout>
答案 2 :(得分:0)
尝试以下布局。 我已经为所有RadioButton分配了相同的权重,以便根据屏幕大小调整其大小。 它的工作正常。根据您的需要更改图片。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/aa"
android:gravity="center"
android:padding="3dp"
android:weightSum="1" >
<RadioGroup
android:id="@+id/radioTur"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rad_anasayfa"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:button="@null"
android:gravity="center"
android:drawableTop="@drawable/ic_circle"
android:onClick="Anasayfa_TIKLA"
android:text="Anasayfa"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" >
</RadioButton>
<RadioButton
android:id="@+id/rad_haber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:button="@null"
android:drawableTop="@drawable/ic_circle"
android:gravity="center"
android:onClick="Haber_TIKLA"
android:text="Haberler"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" >
</RadioButton>
<RadioButton
android:id="@+id/rad_duyuru"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:button="@null"
android:drawableTop="@drawable/ic_circle"
android:gravity="center"
android:onClick="Duyuru_TIKLA"
android:text="Duyurular"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" >
</RadioButton>
<RadioButton
android:id="@+id/rad_yemek"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:button="@null"
android:drawableTop="@drawable/ic_circle"
android:gravity="center"
android:onClick="Yemek_TIKLA"
android:text="Yemek"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" >
</RadioButton>
<RadioButton
android:id="@+id/rad_search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:button="@null"
android:drawableTop="@drawable/ic_circle"
android:gravity="center"
android:onClick="Arama_TIKLA"
android:text="Arama"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" >
</RadioButton>
</RadioGroup>
</LinearLayout>