Reputation: 336
its a simple linear layout with 1 ImageView and 6 TextViews and a ScrollView but TextViews are appearing at the end of the screen and not below ImageView. I have tried editing my dp values in styles.xml but still not working please have a look!! I have also tried editing my ImageView tags but still not working and don't know why TextViews are appearing at the end of the screen and if I remove ScrollView the texts are not visible.
Layout code:
<?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>
Styles.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>
Upvotes: 1
Views: 1208
Reputation: 64
Don't use Scrollview as parent view and add android:adjustViewBounds="true" to Imageview for fit.
<LinearLayout 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">
<ScrollView
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"
>
<ImageView
android:scaleType="fitStart"
android:layout_width="match_parent"
android:adjustViewBounds="true"
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>
</LinearLayout>
Upvotes: 1
Reputation: 1433
Try this!
In your <ImageView>
scaleType is android:scaleType="fitStart"
change it to android:scaleType="fitXY"
Upvotes: 1
Reputation: 69709
You ImageView
hight is wrap_content
this the reason why your textview
are at the bottom of your screen
Try this set static height to your ImageView
<ImageView
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="150dp"
android:contentDescription="@string/photo_description"
android:src="@drawable/photo"
android:id="@+id/image"/>
Upvotes: 2