[英]GWT's analog for Android LinearLayout's layout_weight property?
[英]Unable to resize images in LinearLayout and Weight property set
我正在嘗試調整圖像的大小並增加圖標的大小,但是我已將它們添加到LinearLayout中,並且每個5個圖標均具有相同的權重。 它們適合自己,因此使我無法增加其圖標大小/高度/寬度。
快照:
這是我的XML:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="horizontal"
android:weightSum="5">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/feed_blue" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/compass" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/circle_blue" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/heart_beat" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/user_icon_female" />
</LinearLayout>
我需要根據需要增加/減小圖標的大小,但是Weight屬性可能會限制該功能。 我怎樣才能做到這一點呢?
對於普通應用,您需要所有android資源的圖像包,例如mipmap-hdpi,mipmap-mdpi,mipmap-nodpi,mipmap-xhdpi,mipmap-xxhdpi,mipmap-xxxhdpi ,如果沒有圖像包,則不應以編程方式更改圖像大小嘗試在所有按鈕中播放vs android:scaleType
,例如android:scaleType="centerCrop"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="horizontal"
android:weightSum="5">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/feed_blue" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/compass" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/circle_blue" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/heart_beat" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/user_icon_female" />
</LinearLayout>
在這種情況下,它們都占總寬度的%20%,您可以通過更改重量輕松更改寬度。 另外,您還可以使用padding屬性更改寬度和高度。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.