【发布时间】:2018-07-17 10:01:45
【问题描述】:
我想在我的整个活动中添加滚动视图。我对每个布局和视图都赋予了权重,因为我希望我的屏幕是通用的。但是通过在我的活动顶部添加滚动视图,它会扰乱我的整个屏幕,我无法看到我的所有文本,并在每件事之间添加了额外的空格。我希望我已经清楚地说明了我的问题,这真的让我很恼火,因为我对每个布局和视图都给予了重视,而不是为什么它会改变我的屏幕视图. 此外,我已经看到这里已经发布了相同问题的解决方案,但我对此并不满意。 我想要的只是滚动整个活动而不干扰布局和文本的简单方法。 这是添加滚动视图后我的活动图像:
这是我的 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="3"
android:background="@drawable/empty"
tools:context=".story_activity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Story Name"
android:textAlignment="center"
android:textColor="#fff"
android:layout_marginTop="5dp"
android:textSize="20sp"
android:textStyle="bold"></TextView>
<!-- android:layout_marginLeft="140dp"-->/>
<LinearLayout
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:weightSum="3"
android:background="@drawable/story_des"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="15dp"
android:alpha="0.8"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/lion"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.3"
android:weightSum="1.2"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This specification does not indicate the behavior, rendering or otherwise, of space characters other than those explicitly identified here as white space characters. For this reason, authors should use appropriate elements and styles to achieve visual formatting effects that involve white space, rather than space characters.This specification does not indicate the behavior, rendering or otherwise, of space characters other than those explicitly identified here as white space characters. For this reason, authors should use appropriate elements and styles to achieve visual formatting effects that involve white space, rather than space characters.This specification does not indicate the behavior, rendering or otherwise, of space characters other than those explicitly identified here as white space characters. For this reason, authors should use appropriate elements and styles to achieve visual formatting effects that involve white space, rather than space characters."
android:padding="15dp"
android:textColor="#fff"
android:textSize="15sp"
android:id="@+id/story_content"/>
<!--android:scrollbars = "vertical"-->
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:orientation="horizontal">
<TextView
android:id="@+id/story_rate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Rate This Story"
android:layout_gravity="center"
android:padding="5dp"
android:layout_marginLeft="10dp"
android:textSize="15sp"
android:textColor="#1e5aaa"
android:textStyle="bold"/>
<ImageView
android:id="@+id/rate"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_toRightOf="@+id/story_rate"
android:src="@drawable/star"
android:layout_gravity="center"
/>
<ImageView
android:id="@+id/rate1"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_toRightOf="@+id/rate"
android:layout_gravity="center"
android:src="@drawable/star"
/>
<ImageView
android:id="@+id/rate2"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_toRightOf="@+id/rate1"
android:src="@drawable/star"
android:layout_gravity="center"
/>
<ImageView
android:id="@+id/rate3"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_toRightOf="@+id/rate2"
android:src="@drawable/star"
android:layout_gravity="center"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="30dp"
android:src="@drawable/line"/>
<RelativeLayout
android:layout_marginBottom="-90dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/author_image"
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:layout_marginBottom="20dp"
android:src="@drawable/as" />
<TextView
android:id="@+id/author_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_marginLeft="2dp"
android:textSize="15dp"
android:textColor="#fff"
android:layout_toRightOf="@+id/author_image"
android:fontFamily="century-gothic"
android:text="Author Title"
/>
<TextView
android:id="@+id/pub_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/author_image"
android:layout_below="@+id/author_title"
android:layout_marginLeft="2dp"
android:textSize="15dp"
android:textColor="#fff"
android:fontFamily="century-gothic"
android:text="Pve sentences, cjajsxa "
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
【问题讨论】:
-
我已经看到了,但我没有从那个问题中得到解决方案。