gpt4 book ai didi

android - 主布局已设置但仅显示包装内容

转载 作者:行者123 更新时间:2023-11-30 00:56:17 25 4
gpt4 key购买 nike

enter image description here我创建一个布局父布局都匹配父但仍然显示只包含包装。我尝试了所有布局设置匹配父级,但它不是全宽显示如何解决此类问题。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightyellow"
android:orientation="vertical">
<include
android:id="@+id/rightLayout"
layout="@layout/header" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/padding_medium"
android:layout_marginRight="@dimen/padding_medium"
android:layout_marginTop="@dimen/padding_large"
android:dividerHeight="@dimen/padding_medium"
android:orientation="horizontal"
android:paddingBottom="@dimen/padding_medium"
android:paddingTop="@dimen/padding_medium">
<Spinner
android:id="@+id/spnSelectEventName"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:background="@drawable/spinner_bg" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/image_bg" />
</LinearLayout>

页眉布局文件是。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/GreenColor"
android:baselineAligned="false"
android:padding="@dimen/padding_medium"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/btn_header_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="true"
android:gravity="center"
android:visibility="gone">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_sidemenu"
android:clickable="false"
android:duplicateParentState="true" />
</LinearLayout>
<TextView
android:id="@+id/txt_middle_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="@dimen/padding_small"
android:layout_marginTop="@dimen/padding_small"
android:gravity="center"
android:layout_weight="1"
android:text="Header Name"
android:textColor="@color/WhiteColor"
android:textSize="@dimen/TextSize_medium"
android:textStyle="bold"
android:visibility="visible" />
<LinearLayout
android:id="@+id/btn_header_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:clickable="true"
android:gravity="center"
android:visibility="gone">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_search_home"
android:clickable="false"
android:duplicateParentState="true" />
</LinearLayout>

最佳答案

Make changes to your Layout as below. Remove unnecessary padding and margins from that Layout. And give some weight to ImageView as well so it will work properly.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_light"
android:orientation="vertical">

<include
android:id="@+id/rightLayout"
layout="@layout/header" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:dividerHeight="5dp"
android:orientation="horizontal"
android:weightSum="2">

<Spinner
android:id="@+id/spnSelectEventName"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="0.5"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>

关于android - 主布局已设置但仅显示包装内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40109586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com