Reputation: 55
I encountered a problem and i didn't find anything like that on internet.
I have two different layout, one for Portrait and one for landscape mode. When I set a text to a textView in my Xml file (Test 123 for exemple), it appears in portrait mode but doesn't in land mode.
This is very confusing because yesterday it was working well and today it is not working and i don't remember changing anything on those xml files.
Here are my xml files
Portrait xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<RelativeLayout
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">
<LinearLayout
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
app:fontFamily="@font/caprina_font"
android:textColor="#ffffff"
android:textAllCaps="true"
android:text="@string/session_comparison"
android:layout_marginBottom="10dp"/>
<LinearLayout
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="1pt"
android:background="@color/white" />
</LinearLayout>
<LinearLayout
android:weightSum="10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_width="50dp"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_thumbs_up"/>
</LinearLayout>
<LinearLayout
android:layout_weight="6"
android:layout_width="0dp"
android:layout_height="wrap_content">
<ImageView
android:layout_marginRight="-8dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="19dp"
app:srcCompat="@drawable/ic_triangle"/>
<TextView
android:id="@+id/etat_de_forme_text"
android:textAlignment="center"
android:text="test 1 2 3"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/blue_all_rounded_shape"
android:textColor="@color/white"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</LinearLayout>
LandScape xml :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
app:fontFamily="@font/caprina_font"
android:textColor="#ffffff"
android:textAllCaps="true"
android:text="@string/session_comparison"
android:layout_marginBottom="10dp"/>
<LinearLayout
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="1pt"
android:background="@color/white" />
</LinearLayout>
<LinearLayout
android:weightSum="11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false">
<LinearLayout
android:layout_marginLeft="20dp"
android:layout_weight="4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:gravity="center">
<ImageView
android:layout_gravity="center"
android:layout_width="50dp"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_thumbs_up"/>
<ImageView
android:layout_marginRight="-8dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="19dp"
app:srcCompat="@drawable/ic_triangle"/>
<TextView
android:id="@+id/etat_de_forme_text"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="test 1 2 3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/blue_all_rounded_shape"
android:textColor="@color/white"/>
</LinearLayout>
<LinearLayout
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<com.github.mikephil.charting.charts.RadarChart
android:id="@+id/chart"
android:visibility="gone"
android:clickable="false"
android:layout_height="400dp"
android:layout_width="match_parent" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
EDIT : I can't post the code because this is too long, so here is a link to download it : https://ufile.io/5js30
Upvotes: 0
Views: 62
Reputation: 923
<LinearLayout
android:weightSum="11"
android:layout_width="match_parent"
android:orientation="horizontal" // <= Add this since you are using...
android:layout_height="wrap_content"
android:baselineAligned="false">
<LinearLayout
android:layout_marginLeft="20dp"
android:layout_weight="4"
android:layout_width="0dp" // <= ...using this.
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:gravity="center">
<ImageView
android:layout_gravity="center"
android:layout_width="50dp"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_thumbs_up"/>
<ImageView
android:layout_marginRight="-8dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="19dp"
app:srcCompat="@drawable/ic_triangle"/>
<TextView
android:id="@+id/etat_de_forme_text"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="test 1 2 3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/blue_all_rounded_shape"
android:textColor="@color/white"/>
</LinearLayout>
<LinearLayout
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<com.github.mikephil.charting.charts.RadarChart
android:id="@+id/chart"
android:visibility="gone"
android:clickable="false"
android:layout_height="400dp"
android:layout_width="match_parent" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Reputation: 1332
Try to remove padding from top and bottom in LandScape.xml
file
<LinearLayout
android:layout_marginLeft="20dp"
android:layout_weight="4"
android:layout_width="0dp"
android:layout_height="wrap_content" <== change to wrap_content
android:layout_marginStart="20dp"
android:gravity="center">
...
<TextView
android:id="@+id/etat_de_forme_text"
android:paddingLeft="10dp"
android:paddingRight="10dp"
//android:paddingTop="10dp" <== remove this
//android:paddingBottom="10dp" <== remove this
android:text="test 1 2 3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/blue_all_rounded_shape"
android:textColor="@color/white"/>
...
</LinearLayout>
Upvotes: 2