Java 如何在ScrollView而不是其他视图中以固定大小划分布局?
我创建了三个子视图。视图A、视图B和视图C。视图A包含三个编辑文本,视图B包含ListView。如果我点击编辑文本,那么我想滚动所有的布局,它工作得很好,但所有的视图都有固定的大小 问题是,如果视图B列表视图元素增加,那么视图C将下降,而不显示视图CJava 如何在ScrollView而不是其他视图中以固定大小划分布局?,java,android,Java,Android,我创建了三个子视图。视图A、视图B和视图C。视图A包含三个编辑文本,视图B包含ListView。如果我点击编辑文本,那么我想滚动所有的布局,它工作得很好,但所有的视图都有固定的大小 问题是,如果视图B列表视图元素增加,那么视图C将下降,而不显示视图C <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tool
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#21252E"
android:orientation="vertical"
android:padding="10dp"
tools:context="all_fregment_here.Order_freg">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="2.80"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="6">
<ProgressBar
android:id="@+id/history_progress_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".70" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2.80"
android:paddingLeft="5dp"
android:text="ORDER"
android:textColor="#fff"
android:textStyle="bold" />
<Switch
android:id="@+id/order_switch_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".90" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".10" />
<ImageButton
android:id="@+id/order_history_btn_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".65"
android:background="@null"
android:src="@drawable/ic_history_gray" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".64"
android:background="@null"
android:id="@+id/order_search_btn_id"
android:padding="5dp"
android:src="@drawable/ic_search_gray"
android:textAllCaps="true"
android:textColor="#fff" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<EditText
android:id="@+id/order_medicinename_edt_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/input_layout"
android:hint="Medicine Name"
android:padding="13dp"
android:textColor="#ffff"
android:textColorHint="#8A8B8F" />
<ImageButton
android:id="@+id/name_check_btn_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="17dp"
android:src="@drawable/ic_search"
android:background="@null" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/input_layout"
android:hint="Quantity"
android:padding="13dp"
android:textColor="#ffff"
android:id="@+id/order_quantity_edt_id"
android:textColorHint="#8A8B8F" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="17dp"
android:id="@+id/order_spiner_btn_id"
android:background="@drawable/ic_spanir"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="13dp"
android:textSize="18dp"
android:text="Doctore Prescription"
android:textColor="#ffff" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:drawableLeft="@drawable/ic_attacher_white"
android:textColor="#fff"
android:id="@+id/order_attachimage_btn_id"
android:background="@drawable/btn_background"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text=" IMAGE" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight=".50"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#fff"
android:id="@+id/order_recycler_id"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1.70"
android:weightSum="1.50"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1.50"
android:gravity="bottom"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_background"
android:text="ORDER"
android:id="@+id/order_order_btn_id"
android:textColor="#fff"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Or by doctor Prescription"
android:textAlignment="center"
android:textSize="20dp"
android:padding="2dp"
android:textColor="#8F9196"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_background"
android:text="IMAGE"
android:drawableLeft="@drawable/ic_attacher_white"
android:id="@+id/order_image_btn_id"
android:textColor="#fff"
android:textStyle="bold"
android:gravity="center|left"
android:paddingLeft="50dip"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
这对您很有用
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:id="@+id/rightLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/lay1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#ff0000" >
<!--Your listview goes here as pr your image-->
<TextView
android:id="@+id/textView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:id="@+id/lay2"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#00ff00" >
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:id="@+id/lay3"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#0000ff">
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</ScrollView>
为您的
列表视图指定固定大小
根据您的要求,将wrap_content
更改为180dp
类似的内容
然后显示你的第三视图…不再隐藏
您可以使用您的布局使所有移动设备兼容,然后您可以使用您的全线性布局大小未给定,给定weight=1
然后所有移动设备都是相同的视图所有移动设备都不能更改,它们在屏幕上都是相同的部分也可以发布xml或使用weightSum selfits not replicate?代码中没有滚动视图。你检查上面的图片我在你使用时发布了scrollview我为你添加了它请你检查我的xml代码,现在我发布了