Android: ScrollView 内的线性布局未显示

标签 android scrollview

ScrollView 内部也有一些线性布局。 当我在 HUAWEI Mate7 上安装该应用程序时,它工作正常。 但在三星 S3 或 LG G3 上,唯一显示的是背景图像,但当我触摸屏幕时,方法正在运行。只有 View 没有显示。 这里是 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>

线性布局里面有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>

我不知道该怎么办!

最佳答案

问题可能与布局的对齐和引力有关;在 ScrollView 的 LinearLayout 子项中,将 android:gravity="center 更改为:android:gravity="top|center"。希望对您有所帮助。

(虽然它不会给你一个错误,你可以删除第二个 xmlns:android="http://schemas.android.com/apk/res/android")

关于Android: ScrollView 内的线性布局未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35597103/

相关文章:

java - 为什么我的 TextToSpeech 没有声音?

android - 在 android 中运行 openCL

java - 使用 ContentValues 将以零开头的字符串编号插入字符串列,但始终删除前导零

android - 专门使用 GraphQl 解析 JSON 数据

android - 包含 recyclerview 和 viewpager 的 ScrollView 不滚动

调整大小时,Android ScrollView 跳来跳去

android - 无法让 ScrollView 工作

android - 如何在Android中获取联系人的所有详细信息

android - 我可以将 Button 放在 ScrollView 内的 ConstraintLayout 的底部吗?

android - 由于 ScrollView,ListView 表现得很奇怪?