2015-06-19 147 views
1

example picture從頂端移動的TextView至底部

在圖像上面我要移動的圖像和其它的TextView下含有紙幣微軟TextView的。我怎樣才能做到這一點?

我現在寫了這個佈局。

<android.support.v7.widget.CardView 
    android:id="@+id/card_tracks" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="180dp" 
    android:layout_gravity="center" 
    android:layout_margin="16dp" 
    android:elevation="7dp"> 

    <LinearLayout 
     android:id="@+id/main_ll" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical"> 

     <ImageView 
      android:id="@+id/speaker_image" 
      android:layout_width="60dp" 
      android:layout_height="60dp" 
      android:layout_margin="10dp" 
      android:adjustViewBounds="true" 
      android:scaleType="centerCrop" 
      android:src="@drawable/default_user"/> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" 
      android:padding="10dp"> 

      <TextView 
       android:id="@+id/speaker_name" 
       android:layout_width="wrap_content" 
       android:layout_height="0dp" 
       android:layout_weight="0.5" 
       android:gravity="center_vertical" 
       android:text="@string/placeholder_speaker_name" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="#000000" 
       android:textStyle="bold"/> 

      <TextView 
       android:id="@+id/speaker_designation" 
       android:layout_width="wrap_content" 
       android:layout_height="0dp" 
       android:layout_weight="0.5" 
       android:gravity="top" 
       android:text="@string/placeholder_speaker_designation" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textColor="#000000" 
       android:textStyle="bold"/> 

     </LinearLayout> 

    </LinearLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/main_ll"> 

     <TextView 
      android:id="@+id/speaker_bio" 
      android:layout_width="326dp" 
      android:layout_height="64dp" 
      android:layout_margin="10dp" 
      android:text="@string/placeholder_speaker_bio" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#000000"/> 
    </RelativeLayout> 

</android.support.v7.widget.CardView> 
+0

或以相對佈局替換此行:android:layout_below =「@ id/main_ll」 with:android:layout_gravity =「bottom」 – Palejandro

+0

這不起作用@Palejandro – mw0907

回答

1

請使用

<android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/card_tracks" 
    android:layout_width="match_parent" 
    android:layout_height="180dp" 
    android:layout_gravity="center" 
    android:layout_margin="16dp" 
    android:elevation="7dp"> 

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

     <LinearLayout 
      android:id="@+id/main_ll" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical"> 

      <ImageView 
       android:id="@+id/speaker_image" 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:layout_margin="10dp" 
       android:adjustViewBounds="true" 
       android:scaleType="centerCrop" 
       android:src="@drawable/icon" /> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:orientation="vertical" 
       android:padding="10dp"> 

       <TextView 
        android:id="@+id/speaker_name" 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="0.5" 
        android:gravity="center_vertical" 
        android:text="placeholder_speaker_name" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:textColor="#000000" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/speaker_designation" 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="0.5" 
        android:gravity="top" 
        android:text="placeholder_speaker_designation" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:textColor="#000000" 
        android:textStyle="bold" /> 

      </LinearLayout> 

     </LinearLayout> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/speaker_bio" 
       android:layout_width="326dp" 
       android:layout_height="64dp" 
       android:layout_margin="10dp" 
       android:text="placeholder_speaker_bio" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textColor="#000000" /> 
     </RelativeLayout> 
    </LinearLayout> 
</android.support.v7.widget.CardView> 
+1

Thanks @lal。這工作。 – mw0907

0

你只需要添加:

android:orientation="vertical" 

你的第一個的LinearLayout,所以TextViews可以得出以下ImageView的。