2015-07-11 53 views
0

我對android編程非常陌生。我創建了一個alert box有一個標題問題和正文包含答案(radio Button)單選按鈕的Android警報對齊問題

1。我想減少標題的堡壘大小(我的問題) 2。下面對齊文本中心無線電選項..

enter image description here

Dialogbox.xml

<?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="wrap_content" 
    android:background="#800080" > 

    <LinearLayout 
     android:id="@+id/namelayout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true"> 

     <TextView 
      android:layout_width="73dp" 
      android:layout_height="50dp" 
      android:gravity="center" 
      android:text="5am-6am" /> 

     <TextView 
      android:layout_width="73dp" 
      android:layout_height="50dp" 
      android:gravity="center" 
      android:text="6am-8am" /> 

     <TextView 
      android:layout_width="73dp" 
      android:layout_height="50dp" 
      android:gravity="center" 
      android:text="6pm-8pm" /> 

     <TextView 
      android:layout_width="73dp" 
      android:layout_height="50dp" 
      android:gravity="center" 
      android:text="8pm-11pm" /> 
    </LinearLayout> 

    <RadioGroup 
     android:id="@+id/radiogroub" 
     android:layout_width="280dp" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/namelayout" 
     android:gravity="center" 
     android:orientation="horizontal" 
     android:layout_centerHorizontal="true"> 

     <RadioButton 
      android:id="@+id/sms1" 
      android:layout_width="60dp" 
      android:layout_height="50dp" /> 

     <RadioButton 
      android:id="@+id/sms2" 
      android:layout_width="60dp" 
      android:layout_height="50dp" /> 

     <RadioButton 
      android:id="@+id/sms3" 
      android:layout_width="60dp" 
      android:layout_height="50dp" /> 

     <RadioButton 
      android:id="@+id/sms4" 
      android:layout_width="60dp" 
      android:layout_height="50dp" /> 
    </RadioGroup> 

    <LinearLayout 
     android:id="@+id/btnlayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/radiogroub" 
     android:gravity="center" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/sendbtn" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:text="Send" /> 

     <Button 
      android:id="@+id/closebtn" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:text="Close" /> 
    </LinearLayout> 

</RelativeLayout> 
+0

你'xml'是完全不同的'screen'你已粘貼在這裏。 – Pankaj

+0

是的...屏幕只是一個演示....我想直接在文本下對齊無線電....我的意思是中心 – PHPCoder

回答

0

使用此佈局:

<?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="fill_parent" 
    android:background="#800080" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/namelayout" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_weight="0" 
     android:orientation="horizontal" 
     android:visibility="visible" > 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="5am-6am" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="6am-8am" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="6pm-8pm" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="8pm-11pm" /> 
    </LinearLayout> 

    <RadioGroup 
     android:id="@+id/radiogroub" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:orientation="horizontal" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" > 

      <RadioButton 
       android:id="@+id/sms1" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" > 

      <RadioButton 
       android:id="@+id/sms2" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" > 

      <RadioButton 
       android:id="@+id/sms3" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" > 

      <RadioButton 
       android:id="@+id/sms4" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" /> 
     </LinearLayout> 
    </RadioGroup> 

    <LinearLayout 
     android:id="@+id/btnlayout" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_weight="0" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/sendbtn" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="Send" /> 

     <Button 
      android:id="@+id/closebtn" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="Close" /> 
    </LinearLayout> 

</LinearLayout> 
+0

對齊是完美的......但不能一次選擇一個選項... – PHPCoder