Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在list的item布局里高度百分比不显示 #34

Open
qq530402037 opened this issue Mar 22, 2017 · 5 comments
Open

在list的item布局里高度百分比不显示 #34

qq530402037 opened this issue Mar 22, 2017 · 5 comments

Comments

@qq530402037
Copy link

在list的item布局里使用app:layout_heightPercent="10%h"的话,控件就不会有高度了,显示不出来。必须要用app:layout_heightPercent="10%sh"才行。
其他地方可以,可是使用sh sw在布局文件预览里看不到效果

@yizems
Copy link

yizems commented Mar 22, 2017

你的item 外层viewgroup 的高度 应该是wrap_content吧,,不对,listview的item高度其实就是wrap_content

@carozhu
Copy link

carozhu commented Mar 23, 2017

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

@qq530402037
Copy link
Author

<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混用,就会出现两个控件设定高度一样但实际显示高度不一样的情况

@cjcj125125
Copy link

您好,弱弱的问一下: 对于值可以取:10%w , 10%h , 10% , 10%sw , 10%sh

这里的sw 和sh 是什么意思??

@yizems
Copy link

yizems commented Jan 9, 2018

@cjcj125125 screen w/h 屏幕宽度高度 ,w/h是基于父View的,sw/sh是基于屏幕的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants