2012-11-03 36 views
0

我目前正在做一個應用程序,我希望在屏幕頂部的圖像視圖(與頂部屏幕的10%的差距)和一個表下4個按鈕在裏面。ImageView的Tablelayout與4個按鈕android

我有現在的問題是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/testhback" 
android:gravity="bottom" > 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginBottom="@dimen/f1" 
    android:adjustViewBounds="true" 
    android:src="@drawable/img1" /> 

<TableLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="@dimen/top2" 
    android:stretchColumns="*" > 

    <TableRow 
     android:id="@+id/tableRow1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button5" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_below="@+id/button4" 
      android:onClick="changepic2" 
      android:text="Breaking Dawn" /> 

     <Button 
      android:id="@+id/button4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/button1" 
      android:layout_alignBottom="@+id/button1" 
      android:layout_alignLeft="@+id/button5" 
      android:layout_alignParentRight="true" 
      android:onClick="changepic3" 
      android:text="New Moon (2)" /> 
    </TableRow> 

    <TableRow 
     android:id="@+id/tableRow3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/button3" 
      android:layout_alignParentLeft="true" 
      android:onClick="changepic" 
      android:text="Twilight (1)" /> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:onClick="changepic1" 
      android:text="Eclipse (3)" /> 
    </TableRow> 
</TableLayout> 

的問題是,我試圖從頂部的表設置頁邊距。但是在每個屏幕上,它看起來都不一樣,我也沒有弄清楚如何讓它自動拍攝,比如說,它下面的頂部線10%,imageview的70%,以及4個按鈕的表的20%它在底部。

回答

0

您可以使用垂直方向的LinearLayout並配置layout_weight屬性以進行此安排。

欲瞭解更多信息,請點擊這裏查看http://blog.stylingandroid.com/archives/297,如果問題仍然存在,請返回。

希望這會有所幫助!

0

你必須使用Android:layout_width = 0dp,安卓weightSum和android:layout_weight

thread應該幫助你

相關問題