【发布时间】:2020-05-05 11:49:26
【问题描述】:
我创建了一个简单的应用程序,它在滚动视图中显示用户名和她的简历。在初始阶段,当我刚刚在 Scroll View 中添加了一个 TextView、一个 ImageView 和一个 TextView 时。但是当我运行该应用程序时,它只显示了最上面的 TextView 以及我刚刚添加的星形 ImageView,而不是 ScrollView 的内容。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/rootLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="@dimen/padding"
android:paddingEnd="@dimen/padding">
<TextView
android:id="@+id/nameTextView"
style="@style/nameStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/shivam_jha" />
<ImageView
android:id="@+id/starImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin"
android:contentDescription="@string/star"
tools:srcCompat="@android:drawable/btn_star_big_on" />
<ScrollView
android:id="@+id/bioScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/layout_margin">
<TextView
android:id="@+id/bioTextView"
style="@style/nameStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.1"
tools:text="@string/test" />
</ScrollView>
</LinearLayout>
这是字符串资源文件:
<resources>
<string name="app_name">About Me App</string>
<string name="shivam_jha">Shivam Jha</string>
<string name="star">star</string>
<string name="test">Hey, this is demo string</string>
</resources>
这是维度资源文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="text_size">20sp</dimen>
<dimen name="small_padding">8dp</dimen>
<dimen name="layout_margin">16dp</dimen>
<dimen name="padding">6dp</dimen>
</resources>
这是样式资源文件:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="nameStyle">
<item name="android:layout_marginTop">@dimen/layout_margin</item>
<item name="android:fontFamily">@font/roboto</item>
<item name="android:paddingTop">@dimen/small_padding</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:textSize">@dimen/text_size</item>
</style>
</resources>
【问题讨论】:
-
您能否改写问题或添加结果的屏幕截图
-
我已经添加了应用运行后的截图。