Android ScrollView 隐藏布局中的顶部内容

标签 android android-layout android-xml android-scrollview

我遇到了一个问题,android ScrollView 开始隐藏我在布局顶部的一对 TextView ,我在这个网站上找到了另一个人,他遇到了这个问题,不幸的是,帮助的人能够得到帮助他们实际上并没有说什么修复它,谁能告诉我这里的修复是什么?

android scrollview hiding top content

任何帮助都会很大,这是我的 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/title_color_dark_transparent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical|center_horizontal|center"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="5dp"
        android:orientation="vertical"
        android:paddingTop="5dp" >

        <TextView
            android:id="@+id/saysomething"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/loading"
            android:textColor="#FFFFFF"
            android:textSize="30dp" />

        <TextView
            android:id="@+id/saysomethinginfo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:text="@string/loading"
            android:textColor="#FFFFFF"
            android:textSize="17dp" />

        <EditText
            android:id="@+id/tweetedittext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/edit_text"
            android:gravity="top"
            android:hint="@string/edittext_hint"
            android:inputType="textCapSentences|textMultiLine|textAutoCorrect|textAutoComplete"
            android:lines="3"
            android:textAppearance="@style/TextAppearance.EditText"
            android:textSize="17dp" />

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/photobutton"
                style="@style/TextAppearance.Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/button_background"
                android:onClick="photobuttonClicked"
                android:text="@string/photobuttontext"
                android:textSize="15dp" />

            <TextView
                android:id="@+id/charactersremaining"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_toLeftOf="@+id/posttweetbutton"
                android:text="@string/characters"
                android:textColor="#FFFFFF"
                android:textSize="20dp" />

            <Button
                android:id="@id/posttweetbutton"
                style="@style/TextAppearance.Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="2dp"
                android:background="@drawable/button_background"
                android:onClick="posttweetbuttonClicked"
                android:text="@string/postbuttonstext"
                android:textSize="15dp" />
        </RelativeLayout>
    </LinearLayout>

    <TextView
        android:id="@+id/photodetails"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textColor="#FFFFFF"
        android:textSize="17dp"
        android:layout_marginTop="8dp"
        android:layout_marginLeft="8dp" />

    <ImageView
        android:id="@+id/iv_pic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp" />
</LinearLayout>

</ScrollView>

最佳答案

找到了! LinearLayout 中的 android:layout_gravity="center" 是罪魁祸首。只需删除它,一切都会好起来的。

关于Android ScrollView 隐藏布局中的顶部内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9916317/

相关文章:

java - 以编程方式居中 WebView

android - 如果另一个 TextView 太长,如何在新行中移动 TextView

android - 具有默认对话框外观和感觉的自定义对话框 - 这可能吗?

java - 无法从同一 Activity 更改 Fragment 内 TextView 的文本

android - 为什么Android Studio显示setupWithNavController不存在?

java - 由于 jill.rar + jack.rar,Android 构建失败

android - findViewById 从膨胀布局返回 Null

Android XML : android:elevation vs. 应用程序:海拔

android - 未知属性android :layout_width, layout_height,id,gravity,layout_gravity,padding

android - 将android中XYplot的背景颜色更改为白色?