Reputation: 5077
On my view I want a small piece of space reserved for a title. Beneath that there must be a textview filling the remaining space. This is how my layout looks like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10sp"
android:layout_marginRight="10sp">
<TextView
android:id="@+id/text_titel"
style="@style/DetailTextTitel"
android:textSize="14sp"
android:layout_weight="0.1"/>
<TextView
android:id="@+id/text1"
style="@style/DetailTextText"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:textSize="10sp"
android:autoLink="web"
android:layout_weight="1.9"/>
</LinearLayout>
However this makes my "text1" Textview center in the middle of the screen with a very small width. My app contains a lot of different layouts (text and image, or 2 images and a small text, one big image) which can be viewed and all work fine except this one. Can someone spot the problem in my layout?
EDIT This are the defined styles for DetailTextTitel and DetailTextText:
<style name="DetailTextTitel">
<item name="android:paddingTop">10sp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#28465a</item>
<item name="android:singleLine">true</item>
<item name="android:textSize">14sp</item>
</style>
<style name="DetailTextText">
<item name="android:textColor">#28465a</item>
<item name="android:textSize">10sp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
EDIT also added a screenshot:
Upvotes: 0
Views: 85
Reputation: 5077
Found the problem. Turns out I was inflating the wrong layout -_-.. Thats what happens when your app contains 50+ different layouts.
However thanks for the support.
Upvotes: 0
Reputation: 133560
You are missing these attributes for textview with id text_titel
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10sp"
android:layout_marginRight="10sp">
<TextView
android:id="@+id/text_titel"
android:textSize="14sp"
android:paddingTop="20dp"
android:text="DetailTextTitel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#28465a"
android:singleLine="true"
android:layout_weight="0.1"/>
<TextView
android:id="@+id/text1"
android:text="DetailTextText"
android:textSize="10sp"
android:textColor="#28465a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:layout_weight="1.9"/>
</LinearLayout>
Upvotes: 1
Reputation: 48404
Not sure this will fix your problem (with Android layouts it's always been a bit of trial and error for me). However why don't you try:
Edit
Upvotes: 1