我有一个动态放大的布局,我有一个 ImageView ,我想始终停留在布局的底部。我的代码如下
<LinearLayout
android:id="@+id/bot"
android:layout_width="300dip"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/descripcion"
android:layout_width="170dip"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/la_descripcion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dfsasdfasfadfasdfasdfasdfasdfasdjfas sdf sadf sadf trh h t 5454 dsdfjsdf sdfsdfhk sdf f sdf hk sdf "
android:textColor="#ffffff"
android:textSize="11sp"
android:paddingLeft="12dp"/>
<ImageView
android:id="@+id/img_tag"
android:layout_width="5.84mm"
android:layout_height="4.21mm"
android:scaleType="centerInside"
android:background="@drawable/agotado"
/>
</LinearLayout>
如果 TextView “la_descripción”更长,“LinearLayout”会放大图像但会保持固定而不是在底部
最佳答案
<ImageView
android:id="@+id/img_tag"
android:layout_width="5.84mm"
android:layout_height="4.21mm"
android:scaleType="centerInside"
android:background="@drawable/agotado"
android:layout_gravity="bottom"
/>
如果你想坚持使用 LinearLayout,应该这样做,否则,如果你切换到 RelativeLayout:
<ImageView
android:id="@+id/img_tag"
android:layout_width="5.84mm"
android:layout_height="4.21mm"
android:scaleType="centerInside"
android:background="@drawable/agotado"
android:alignParentBottom="true"
/>
关于android - 当布局具有属性 android : layout_height = "wrap_content"? 时,如何在布局底部设置元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21189410/