2014-07-11 62 views
0

我試圖顯示從佈局頁面中間開始的表格行。當我做代碼表行總是顯示在頂部,在android中的表格佈局底部顯示錶格

我試圖用相對佈局實現表格佈局。這沒有奏效。 我改變了layout_height =「200dp」選項。這也沒有奏效。

我該如何解決這個問題?

,我試圖代碼如下

<TableLayout 
android:layout_width="match_parent"   
android:layout_height="match_parent" 
android:showDividers="middle" 
android:shrinkColumns="*" 
android:stretchColumns="*" 
android:background="#ffffff"> 

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

    <ImageView 
    android:id="@+id/sunsign" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:contentDescription="@string/sunsign" 
    android:onClick="onClick" 
    android:src="@drawable/sunsign" 
    android:gravity="center" 
    android:padding="20dip" 
    android:background="#17543F"/> 

    <ImageView 
    android:id="@+id/services" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:contentDescription="@string/services" 
    android:onClick="onClick" 
    android:src="@drawable/services" 
    android:gravity="center" 
    android:padding="20dip" 
    android:background="#17543F"/> 

    <ImageView 
    android:id="@+id/sermons" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  
    android:src="@drawable/sermons" 
    android:contentDescription="@string/sermons" 
    android:onClick="onClick" 
    android:gravity="center" 
    android:padding="20dip" 
    android:background="#17543F"/> 

+0

你能解釋一下你想要的圖片嗎?或試圖澄清這一點?我不確定你想要什麼與發生什麼。 –

+0

你的tablelayout是你的主佈局,你不能「移動」到中間,除非你實現2 linearLayouts第一個站在屏幕的第一半,第二個與tablelayout內(例如!) – PedroHawk

+0

@NathanielWaggoner -can你可以看看這個網址的圖片(https://drive.google.com/file/d/0Bze-JWq18hkVRTUyWmFuM2dDb0E/edit?usp=sharing) –

回答

0

試試這個:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

    <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight=".5" 
      /> 
    <TableLayout 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight=".5" 
      /> 

</LinearLayout> 

的layout_weight值可以讓你充滿整個屏幕的百分比。文本視圖在這裏是一個佔位符 - 你可以在其中放置任何你想要的東西。

+0

這工作完美。非常感謝.... –

0

試試你的TableRow的重心位置設定爲 「底部」。

<TableRow 
    android:id="@+id/tableRow1" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:gravity="bottom" > 
...