表格布局中的问题

时间:2011-09-10 07:13:36

标签: android android-layout

弹出:关闭按钮区域和边框线在纵向模式下不够宽。

在纵向模式下测试手机。 将SMS或MMS发送到测试的手机。 观察“关闭”按钮和边框线之间区域中的弹出窗口。

实际结果:关闭按钮和边框线之间的区域不够宽。视图 屏幕截图 预期结果:关闭按钮和边界线之间的区域应类似于回复 按钮到边界线。

在横向模式的情况下无法重新生成..

<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:background="#00000000">
<RelativeLayout 
            android:layout_height="wrap_content"
            android:layout_width="300dp">   
<LinearLayout
  android:layout_width="300dp"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:layout_gravity="center">
   <TextView
            android:id="@+id/unread_messges_text" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:padding="5dp" />
    <View
         android:layout_height="1dp" 
         android:layout_width="fill_parent"
         android:background="@color/background_light"
      />
    <RelativeLayout 
            android:layout_height="wrap_content" 
            android:layout_width="fill_parent"
            android:layout_margin="5dp"
            >
            <ImageView
                    android:id="@+id/contact_photo"
                    android:scaleType="centerCrop" 
                android:layout_width="70dp" 
                android:layout_height="70dp"
                />
            <TextView
                android:id="@+id/sender_name_number" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/contact_photo"
                android:textSize="20dp"
                android:singleLine="true"
                android:layout_marginLeft="5dp"
                />
            <TextView
                android:id="@+id/message_subject" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/contact_photo"
                android:layout_below="@+id/sender_name_number"
                android:textSize="15dp"
                android:singleLine="true"
                android:layout_marginLeft="5dp"
                />    
            <TextView
                android:id="@+id/message_received_time" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/contact_photo"
                android:layout_below="@+id/message_subject"
                android:text="@string/message_received_time"
                android:layout_marginLeft="5dp"
                />
    </RelativeLayout>
    <View
         android:layout_height="1dp" 
         android:layout_width="fill_parent"
         android:background="@color/background_light"
      />
     <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/message_body_textpart"
        android:layout_margin="5dp"
       >
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/message_body_imagepart"
        android:layout_marginLeft="5dp"
        android:layout_marginBottom="4dp"
        android:layout_marginRight="5dp"
       >
    </RelativeLayout>

   <TableLayout
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent"
          android:background="@color/background_light"
          android:stretchColumns="*">
       <TableRow
          android:layout_gravity="center_horizontal"
          android:layout_marginTop="3dp"
          >  
       <Button 
             android:text="@string/reply_button_text" 
             android:id="@+id/reply_button" 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content"/>
       <Button 
             android:id="@+id/next_button" 
             android:text="@string/next_button_text" 
             android:layout_height="wrap_content" 
             android:layout_width="wrap_content"/>
       <Button 
             android:text="@string/close_button_text" 
             android:id="@+id/close_button" 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content"
             />
       </TableRow>  
   </TableLayout>

</LinearLayout>
</RelativeLayout>
</ScrollView>

2 个答案:

答案 0 :(得分:1)

我会尝试水平LinearLayout而不是底部3个按钮的表格视图。将每个按钮的宽度设置为0dip,将layout_weight设置为1.

<LinearLayout
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"
      android:background="@color/background_light">
   <Button 
         android:text="@string/reply_button_text" 
         android:id="@+id/reply_button" 
         android:layout_width="0dip" 
         android:layout_height="wrap_content"
         android:layout_weight="1"/>
   <Button 
         android:id="@+id/next_button" 
         android:text="@string/next_button_text" 
         android:layout_height="wrap_content" 
         android:layout_width="0dip"
         android:layout_weight="1"/>
   <Button 
         android:text="@string/close_button_text" 
         android:id="@+id/close_button" 
         android:layout_width="0dip"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         />
</LinearLayout>

答案 1 :(得分:0)

android:layout_marginTop="3dp"TableRow按钮更改为android:padding="3dp"

padding is for padding space between layout and its child

margin is for padding space between layout and its parent
相关问题