【问题标题】:Android ImageView layout alignmentAndroid ImageView 布局对齐
【发布时间】:2014-03-05 18:58:11
【问题描述】:

如何更改我的布局以使图像 1 更像图像 2?我不介意是向上移动的文本还是向上移动的图像。

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

    <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>

【问题讨论】:

  • 尝试将 Gravity 设置为 LinearLayoutImageView android:layout_gravity="top"
  • 地牢爬行猫!

标签: android imageview alignment


【解决方案1】:

接受的答案对我不起作用。这是我的解决方案

将 android:scaleType="fitStart" 添加到 ImageView。

【讨论】:

  • 是的,这对我有用,并且接受的答案对我也没有用。
【解决方案2】:

试试这个..

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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-01
    • 1970-01-01
    • 2014-01-12
    • 2012-12-09
    相关资源
    最近更新 更多