[英]Android: Linear layout inside scrollview is not showing
There are some linear layout inside scrollview as well. 在scrollview中也有一些线性布局。 when i install the app on HUAWEI Mate7 it works just fine.
当我在HUAWEI Mate7上安装应用程序时,它可以正常工作。 but on Samsung S3 or LG G3 the only thing that shows is background image but when i touch the screen, methods are working.
但是在Samsung S3或LG G3上,唯一显示的是背景图像,但是当我触摸屏幕时,方法仍然有效。 only views are not showing.
仅视图未显示。 here is mainActivity.xml
这是mainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back1"
android:alpha=".9">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha=".9"
android:gravity="center">
</LinearLayout>
</ScrollView>
</RelativeLayout>
inside the linear layout there are 20 of this 线性布局中有20个
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp" >
<ImageButton
android:layout_width="0dp"
android:layout_height="fill_parent"
android:id="@+id/imageButton7"
android:src="@drawable/can_pot_com"
android:scaleType="fitStart"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_weight="2" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/can_pot"
android:id="@+id/button6"
android:textStyle="bold"
android:textIsSelectable="false"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:background="#00ffffff"
android:layout_weight="3" />
</LinearLayout>
I don't know what do to! 我不知道该怎么办!
The problem is related probably with the align and gravity of the layouts; 问题可能与布局的对齐方式和重力有关。 in the LinearLayout child inside the ScrollView, change the
android:gravity="center
by: android:gravity="top|center"
. Hope it helps. 在ScrollView内的LinearLayout子级中,将
android:gravity="center
更改为: android:gravity="top|center"
希望对您有所帮助。
(And and although it does not give you an error, you can remove the second xmlns:android="http://schemas.android.com/apk/res/android") (并且尽管它没有给您错误,但是您可以删除第二个xmlns:android =“ http://schemas.android.com/apk/res/android”)
I had a similar problem. 我有一个类似的问题。 The LinearLayout inside my ScrollView was not working as expected.
ScrollView内部的LinearLayout未能按预期工作。 The first component of the lineaLayout was not visible.
lineaLayout的第一个组件不可见。 The reason was android:layout_gravity="center_vertical".
原因是android:layout_gravity =“ center_vertical”。 Change that to android:layout_gravity="top|center_vertical".
将其更改为android:layout_gravity =“ top | center_vertical”。
从滚动视图中删除此行
xmlns:android="http://schemas.android.com/apk/res/android"
try this code 试试这个代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back1"
android:alpha=".9"> <ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha=".9"
android:gravity="center">
</LinearLayout>
</ScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.