我正在開發一個顯示一些圖像的應用程序。但是當我顯示 ImageView 時,它會擴展父線性布局。我怎樣才能解決這個問題?<ScrollView android:layout_height="wrap_content" android:layout_width="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/linearlayoutround" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_marginTop="2dp" android:layout_marginBottom="10dp" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <de.hdodenhof.circleimageview.CircleImageView android:layout_width="32dp" android:layout_height="32dp" android:layout_margin="5dp" android:src="@drawable/testimage" /> <TextView android:layout_width="match_parent" android:layout_height="32dp" android:textColor="@color/White" android:layout_marginTop="5dp" android:layout_marginLeft="44dp" android:textSize="24dp" android:text="Admin" /> </RelativeLayout> <ImageView android:id="@+id/testtest" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:layout_marginRight="1dp" android:layout_marginLeft="1dp" android:src="@drawable/testimage"/> </LinearLayout> </LinearLayout></ScrollView>我要這個:但顯示這個:
1 回答

天涯盡頭無女友
TA貢獻1831條經驗 獲得超9個贊
嘗試使用android:adjustViewBounds屬性
將其添加到ImageView中,如下所示:
<ImageView
android:id="@+id/testtest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_marginLeft="1dp"
android:adjustViewBounds="true"
android:src="@drawable/testimage"/>
- 1 回答
- 0 關注
- 169 瀏覽
添加回答
舉報
0/150
提交
取消