【发布时间】:2018-02-28 11:41:08
【问题描述】:
它是一个简单的线性布局,有 1 个 ImageView 和 6 个 TextViews 以及一个 ScrollView,但 TextViews 出现在屏幕的末尾而不是 ImageView 下方。我已经尝试在 styles.xml 中编辑我的 dp 值,但仍然无法正常工作,请看一下!! 我也尝试过编辑我的 ImageView 标签,但仍然无法正常工作,不知道为什么 TextViews 会出现在屏幕末尾,如果我删除 ScrollView,文本将不可见。
布局代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#000000"
tools:context="com.example.stan.sportbusinesscard.MainActivity">
<ImageView
android:scaleType="fitStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/photo_description"
android:src="@drawable/photo"
android:id="@+id/image"/>
<TextView
style="@style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title" />
<TextView
style="@style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text1"/>
<TextView
style="@style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/where" />
<TextView
style="@style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/address"
android:autoLink="map"/>
<TextView
style="@style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/when" />
<TextView
style="@style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dateOf" />
</LinearLayout>
</ScrollView>
样式.xml:
<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="LightText" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="android:paddingLeft">18dp</item>
<item name="android:paddingRight">18dp</item>
<item name="android:textColor">#aaaaaa</item>
</style>
<style name="TitleText" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="android:paddingLeft">18dp</item>
<item name="android:paddingRight">18dp</item>
<item name="android:paddingTop">20dp</item>
<item name="android:textSize">18sp</item>
<item name="android:textColor">#FFD700</item>
</style>
</resources>
【问题讨论】:
-
降低图像高度或固定 ImageView 高度。
-
尝试给图像固定高度。
标签: java android android-layout android-linearlayout android-scrollview