Android ImageView布局对齐

问题描述:

如何更改布局以使图像1更像图像2?我不介意它是向上移动的文字还是向上移动的图像。Android ImageView布局对齐

What I have

What I need

我的布局文件是像这样: -

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

     <LinearLayout 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.6" 
      android:orientation="vertical" > 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:src="@drawable/imp" /> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" 
      android:orientation="vertical" > 

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

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/stats_chr" /> 
       <TextView 
        android:layout_width="0dip" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:gravity="right|center_vertical" 
        android:singleLine="true" 
        android:text="AA" /> 
      </LinearLayout> 
+0

尝试将Gravity设置为您的'LinearLayout'和'ImageView'两个'android:layout_gravity =“top”' –

+1

地牢爬行猫! –

试试这个..

使用android:gravity="top"LinearLayoutandroid:layout_gravity="top"ImageView

 <LinearLayout 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:gravity="top" 
      android:layout_weight="0.6" 
      android:orientation="vertical" > 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="top" 
       android:src="@drawable/imp" /> 

     </LinearLayout> 

接受的答案不适用于我。这里是我的解决方案

将android:scaleType =“fitStart”添加到ImageView。

+0

是的,这工作,我接受的答案也没有工作过。 –