2013-01-15 32 views
-1

我有一個在同一行上有一個imageview和textview的XML佈局。這工作完美,但現在我想在這下面放置三個按鈕,我不能找出什麼佈局來實現這些按鈕,因爲佈局只是在圖像和文本視圖之間的行內設置。XML佈局,在一個列表視圖/文本視圖下的按鈕

下圖顯示了我試圖實現什麼。 (B1,B2和B3代表按鈕)

layout

誰能給我推在如何我能得到這個佈局方向是正確的?

我的繼承人XML:現在放錯地方的TextView

<?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:orientation="horizontal" > 

<ImageView 
    android:id="@+id/imgLink" 
    android:layout_width="78dp" 
    android:layout_height="match_parent" 
    android:src="@drawable/cons" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 



     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="match_parent" 
      android:layout_height="75dp" 
      android:gravity="center" 
      android:text="Contacts" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textSize="40sp" /> 

    </LinearLayout> 

</LinearLayout> 

佈局/佈局 anotherlayout

+0

你可以做一個相對佈局instea d並根據需要使用layout_below和layout_toRightOf參數。 – sam

+0

@ user1352057嘗試發佈解決方案,根據您的要求設置佈局。 –

回答

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="wrap_content" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <ImageView 
      android:id="@+id/imgLink" 
      android:layout_width="78dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_weight="1" 
      android:src="@drawable/cons" /> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="match_parent" 
      android:layout_height="75dp" 
      android:gravity="center" 
      android:text="Contacts" 
      android:layout_weight="1" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textSize="40sp" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <Button 
      android:id="@+id/b1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="20dp" 
      android:text="b1" /> 

     <Button 
      android:id="@+id/b2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="20dp" 
      android:text="b2" /> 

     <Button 
      android:id="@+id/b3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="20dp" 
      android:text="b3" /> 
    </LinearLayout> 

</LinearLayout> 
+0

definetly給了我想要的佈局,但它掩蓋了我的textview和imageview的佈局。如第一篇文章所示,編輯 – user1352057

+0

@ user1352057我現在編輯了我的答案,文本「聯繫人」的textview將位於中心。如果我沒有錯,我認爲你對此感到擔憂? –

+0

@Praik。非常感謝你的回答。我設法通過重新調整線性佈局來自己排序。 – user1352057