RemoteView设置高度
阅读原文时间:2023年07月11日阅读:2

刚开始内层LinearLayout直接用

android:layout_height="match_parent"


<LinearLayout  
    android:id="@+id/layout\_home"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent">

    <ImageView  
        android:id="@+id/btn\_home"  
        android:layout\_width="24dp"  
        android:layout\_height="24dp"  
        android:src="@mipmap/ic\_notification\_bar\_home"/>

    <TextView  
        android:id="@+id/tv\_home"  
        android:textColor="@color/white"  
        android:text="@string/noti\_home"  
        android:textSize="@dimen/sp\_12"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />  
</LinearLayout>

<ImageView  
    android:background="#ffffff"  
    android:alpha="0.2"  
    android:layout\_width="@dimen/dp\_0\_5"  
    android:layout\_height="@dimen/dp\_28"/>

<LinearLayout  
    android:id="@+id/layout\_junk"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent">

    <ImageView  
        android:id="@+id/btn\_junk"  
        android:layout\_width="24dp"  
        android:layout\_height="24dp"  
        android:background="@mipmap/ic\_notification\_bar\_junk"/>

    <TextView  
        android:id="@+id/tv\_junk"  
        android:text="@string/noti\_junk"  
        android:textSize="@dimen/sp\_12"  
        android:textColor="@color/white"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />

</LinearLayout>

<ImageView  
    android:background="#ffffff"  
    android:alpha="0.2"  
    android:layout\_width="@dimen/dp\_0\_5"  
    android:layout\_height="@dimen/dp\_28"/>

<LinearLayout  
    android:id="@+id/layout\_boost"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent">

    <ImageView  
        android:id="@+id/img\_boost"  
        android:layout\_width="24dp"  
        android:layout\_height="24dp" />

    <TextView  
        android:id="@+id/tv\_boost"  
        android:textColor="@color/white"  
        android:text="@string/noti\_boost"  
        android:textSize="@dimen/sp\_12"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />  
</LinearLayout>

<ImageView  
    android:background="#ffffff"  
    android:alpha="0.2"  
    android:layout\_width="@dimen/dp\_0\_5"  
    android:layout\_height="@dimen/dp\_28"/>

<LinearLayout  
    android:id="@+id/layout\_cpu"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent">

    <FrameLayout  
        android:layout\_width="24dp"  
        android:layout\_height="24dp">

        <ImageView  
            android:id="@+id/btn\_cpu"  
            android:layout\_width="wrap\_content"  
            android:layout\_height="wrap\_content"  
            android:src="@mipmap/ic\_notification\_bar\_cpu"/>

        <ImageView  
            android:id="@+id/cpu\_warn\_icon"  
            android:visibility="invisible"  
            android:src="@mipmap/img\_cpu\_warn"  
            android:layout\_gravity="bottom|right"  
            android:layout\_width="wrap\_content"  
            android:layout\_height="wrap\_content" />

    </FrameLayout>

    <TextView  
        android:id="@+id/tv\_cpu"  
        android:textColor="@color/white"  
        android:text="@string/noti\_cpu"  
        android:textSize="@dimen/sp\_12"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />  
</LinearLayout>

后来改成这样:

内层LinearLayout设置为:android:layout_height="64dp"


<LinearLayout  
    android:id="@+id/layout\_home"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="64dp">

    <ImageView  
        android:id="@+id/btn\_home"  
        android:layout\_width="24dp"  
        android:layout\_height="24dp"  
        android:src="@mipmap/ic\_notification\_bar\_home"/>

    <TextView  
        android:id="@+id/tv\_home"  
        android:textColor="@color/white"  
        android:text="@string/noti\_home"  
        android:textSize="@dimen/sp\_12"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />  
</LinearLayout>

<ImageView  
    android:background="#ffffff"  
    android:alpha="0.2"  
    android:layout\_width="@dimen/dp\_0\_5"  
    android:layout\_height="@dimen/dp\_28"/>

<LinearLayout  
    android:id="@+id/layout\_junk"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent">

    <ImageView  
        android:id="@+id/btn\_junk"  
        android:layout\_width="24dp"  
        android:layout\_height="24dp"  
        android:background="@mipmap/ic\_notification\_bar\_junk"/>

    <TextView  
        android:id="@+id/tv\_junk"  
        android:text="@string/noti\_junk"  
        android:textSize="@dimen/sp\_12"  
        android:textColor="@color/white"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />

</LinearLayout>

<ImageView  
    android:background="#ffffff"  
    android:alpha="0.2"  
    android:layout\_width="@dimen/dp\_0\_5"  
    android:layout\_height="@dimen/dp\_28"/>

<LinearLayout  
    android:id="@+id/layout\_boost"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent">

    <ImageView  
        android:id="@+id/img\_boost"  
        android:layout\_width="24dp"  
        android:layout\_height="24dp" />

    <TextView  
        android:id="@+id/tv\_boost"  
        android:textColor="@color/white"  
        android:text="@string/noti\_boost"  
        android:textSize="@dimen/sp\_12"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />  
</LinearLayout>

<ImageView  
    android:background="#ffffff"  
    android:alpha="0.2"  
    android:layout\_width="@dimen/dp\_0\_5"  
    android:layout\_height="@dimen/dp\_28"/>

<LinearLayout  
    android:id="@+id/layout\_cpu"  
    android:gravity="center"  
    android:orientation="vertical"  
    android:layout\_weight="1"  
    android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent">

    <FrameLayout  
        android:layout\_width="24dp"  
        android:layout\_height="24dp">

        <ImageView  
            android:id="@+id/btn\_cpu"  
            android:layout\_width="wrap\_content"  
            android:layout\_height="wrap\_content"  
            android:src="@mipmap/ic\_notification\_bar\_cpu"/>

        <ImageView  
            android:id="@+id/cpu\_warn\_icon"  
            android:visibility="invisible"  
            android:src="@mipmap/img\_cpu\_warn"  
            android:layout\_gravity="bottom|right"  
            android:layout\_width="wrap\_content"  
            android:layout\_height="wrap\_content" />

    </FrameLayout>

    <TextView  
        android:id="@+id/tv\_cpu"  
        android:textColor="@color/white"  
        android:text="@string/noti\_cpu"  
        android:textSize="@dimen/sp\_12"  
        android:layout\_width="wrap\_content"  
        android:layout\_height="wrap\_content" />  
</LinearLayout>

  就可以看到通知栏变高了

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器