在list的item布局里高度百分比不显示
在list的item布局里使用app:layout_heightPercent="10%h"的话,控件就不会有高度了,显示不出来。必须要用app:layout_heightPercent="10%sh"才行。 其他地方可以,可是使用sh sw在布局文件预览里看不到效果
你的item 外层viewgroup 的高度 应该是wrap_content吧,,不对,listview的item高度其实就是wrap_content
@qq530402037 请问下你是怎么做的,我怎么搞在列表里也显示不出来。如下:
<com.zhy.android.percent.support.PercentLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="0dp" android:layout_height="0dp" android:orientation="vertical" app:layout_heightPercent="100%sh" app:layout_widthPercent="100%sw" >
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#00000000"
android:gravity="center_horizontal|bottom"
android:text="星期二"
android:textColor="@color/white"
app:layout_heightPercent="35%sh"
app:layout_textSizePercent="18%sh"
app:layout_widthPercent="100%" />
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:src="@drawable/s_overcast_day"
app:layout_heightPercent="30%sh"
app:layout_marginTopPercent="5%"
app:layout_widthPercent="30%" />
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#00000000"
android:gravity="center"
android:text="16°-24°"
android:textColor="@color/white"
app:layout_heightPercent="35%sh"
app:layout_textSizePercent="18%sh"
app:layout_widthPercent="100%" />
</com.zhy.android.percent.support.PercentLinearLayout>
<com.zhy.android.percent.support.PercentLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/holo_green_light"
android:text="啊啊啊啊啊啊啊啊啊啊"
android:gravity="center"
app:layout_heightPercent="20%h"
app:layout_widthPercent="80%w"
app:layout_textSizePercent="5%w"
/>
<com.zhy.android.percent.support.PercentLinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/holo_blue_light"
android:text="aaa"
android:gravity="center"
app:layout_heightPercent="20%sh"
app:layout_widthPercent="40%sw"
app:layout_textSizePercent="5%w"
/>
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/holo_blue_light"
android:text="bbbbb"
android:gravity="center"
app:layout_heightPercent="20%sh"
app:layout_widthPercent="40%sw"
app:layout_textSizePercent="5%w"
/>
</com.zhy.android.percent.support.PercentLinearLayout>
</com.zhy.android.percent.support.PercentLinearLayout> sw sh在预览图里就是不显示的 而且还有个问题,一个item同一行的两个控件,要么都用w,sw,要么都用sh,如果s,sw 和sh混用,就会出现两个控件设定高度一样但实际显示高度不一样的情况
您好,弱弱的问一下: 对于值可以取:10%w , 10%h , 10% , 10%sw , 10%sh
这里的sw 和sh 是什么意思??
@cjcj125125 screen w/h 屏幕宽度高度 ,w/h是基于父View的,sw/sh是基于屏幕的