I want my Landspace to look like this
but it looks like this when I use a RelativeLayout
I also tried with LinearLayout, but it didn't work.
Here is my xml code
<?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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal|center_vertical"
tools:context="co.edu.unal.androidtic_tac_toe.AndroidTicTacToeActivity"
android:orientation="horizontal">
<co.edu.BoardView
android:id="#+id/board"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginTop="5dp"/>
<TextView
android:id="#+id/information"
android:layout_width="144dp"
android:layout_height="wrap_content"
android:text="info"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:textSize="20sp" />
<TextView
android:id="#+id/scores"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Human: 0 Ties:0 Android:0"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:textSize="20sp" />
</LinearLayout>
Maybe do something like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<co.edu.BoardView
android:id="#+id/board"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="5dp"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:id="#+id/TextView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="Name" />
<TextView
android:id="#+id/TextView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="Name" />
<TextView
android:id="#+id/TextView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Name" />
<TextView
android:id="#+id/TextView8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Name" />
</LinearLayout>
Related
How can i create some TextView beside an ImageView in xml? I've tried my best, but still I can't make it.
Like this:
Display frame
I need 4 texts containing the title and description. The texts are intended to describe the image, any pointers or help would be appreciated
This is my xml code(end up getting a messy layout)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="#android:color/white"
android:padding="#dimen/activity_vertical_margin"
android:orientation="vertical"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img_item_photo"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
android:src="#drawable/oneplus_7_pro_r1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/img_item_photo"
android:layout_toRightOf="#id/img_item_photo"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="165dp"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
android:text="#string/Hape_name"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_item_Desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_horizontal_margin" />
</LinearLayout>
</RelativeLayout>
Just remove android:layout_marginBottom="165dp" from your textview
Try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="#android:color/white"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img_item_photo"
android:layout_width="150dp"
android:layout_height="200dp"
android:src="#drawable/ic_search_black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/img_item_photo"
android:layout_toRightOf="#id/img_item_photo"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/load_available"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_item_Desc"
android:text="#string/load_available"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
Also, try with LinearLayout
<?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"
android:layout_width="match_parent"
android:background="#android:color/white"
android:orientation="horizontal"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/img_item_photo"
android:layout_width="150dp"
android:layout_height="200dp"
android:src="#drawable/ic_search_black" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/load_available"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/load_available"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/load_available"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_item_Desc"
android:text="#string/load_available"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
You can simply do this view using ConstraintLayout and it will look like below image and I posted the XML also use this:
Small Note: AndroidX is used here. If you are not familiar with androidX then, please take a small break to know about androidX and then try this.
if you are using support library (not androidX) then replace androidx.constraintlayout.widget.ConstraintLayout with android.support.constraint.ConstraintLayout in below code
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/avatars" />
<TextView
android:id="#+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_8dp"
android:text="textView 1"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#color/black"
app:layout_constraintBottom_toTopOf="#id/tv_2"
app:layout_constraintStart_toEndOf="#id/imageView1"
app:layout_constraintTop_toTopOf="#id/imageView1" />
<TextView
android:id="#+id/tv_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_8dp"
android:text="textView 2"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#color/black"
app:layout_constraintBottom_toTopOf="#id/tv_3"
app:layout_constraintStart_toEndOf="#id/imageView1"
app:layout_constraintTop_toBottomOf="#id/tv_1" />
<TextView
android:id="#+id/tv_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_8dp"
android:text="textView 3"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#color/black"
app:layout_constraintBottom_toTopOf="#id/tv_4"
app:layout_constraintStart_toEndOf="#id/imageView1"
app:layout_constraintTop_toBottomOf="#id/tv_2" />
<TextView
android:id="#+id/tv_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_8dp"
android:text="textView 4"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#color/black"
app:layout_constraintBottom_toBottomOf="#id/imageView1"
app:layout_constraintStart_toEndOf="#id/imageView1"
app:layout_constraintTop_toBottomOf="#id/tv_3" />
</androidx.constraintlayout.widget.ConstraintLayout>
You can use layout weight for better result in every case,as shown below,...
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:TextViewandroid="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/icons"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="#dimen/margin_10dp"
android:layout_weight="1"
android:background="#color/icons"
android:gravity="center">
<ImageView
android:id="#+id/img_item_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/background_img" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#color/icons">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/style_curve_accent"
android:text="Title"
android:textSize="#dimen/margin_15sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/style_edittext"
android:text="Descripltion is Here. Descripltion is Here."
android:textSize="#dimen/margin_15sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:layout_marginTop="#dimen/margin_5dp"
android:background="#drawable/style_curve_accent"
android:text="Title"
android:textSize="#dimen/margin_20dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/style_edittext"
android:text="Descripltion is Here.Descripltion is Here."
android:textSize="#dimen/margin_15sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/style_curve_accent"
android:text="Title"
android:textSize="#dimen/margin_20dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/style_edittext"
android:text="Descripltion is Here.Descripltion is Here."
android:textSize="#dimen/margin_15sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/style_curve_accent"
android:text="Title"
android:textSize="#dimen/margin_20dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/style_edittext"
android:text="Description is here. Description is Here."
android:textSize="#dimen/margin_15sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
Hope this it will help you!
Thanks!!
Though your code seems fine with minor improvements.
Here is some alternate code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#android:color/white"
android:padding="#dimen/activity_vertical_margin"
android:orientation="horizontal"
android:layout_height="match_parent">
<ImageView
android:padding="10dp"
android:layout_weight="1"
android:id="#+id/img_item_photo"
android:layout_width="0dp"
android:layout_height="200dp"
android:src="#drawable/side_nav_bar" />
<LinearLayout
android:padding="10dp"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_item_Desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test 1"
/>
<TextView
android:id="#+id/tv_item_name1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test"
android:layout_marginTop="5dp"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_item_Desc2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test 2"
/>
</LinearLayout>
Here is solution,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_item_photo"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin" />
<LinearLayout
android:id="+#id/layout_field"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tv_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
android:text="Hape_name"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_item_Desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_horizontal_margin" />
</LinearLayout>
</LinearLayout>
Add more textView inside layout_field.
I got trouble with android layout in xamarin. How to fill space without overlapping the layout in android xml?
This layout confusing me. Because it's not like php or xaml. I want to make the layout view like this:
I'm using nexus 6 in design windows. When I ran the debug in emulator the view become like this:
The layout overlapping. I wonder how to fill blank space in android layout size so it can fit in my device (dynamically)?
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/main_content"
android:gravity="fill_horizontal|bottom">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="610.3dp"
android:layout_weight="1"
android:gravity="center|bottom">
<TextView
android:text="Location Detail"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView9"
android:layout_marginTop="10dp"
android:gravity="center" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="199.3dp"
android:id="#+id/linearLayout1"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout2">
<TextView
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailName" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout3"
android:layout_marginTop="5dp">
<TextView
android:text="Address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView4"
android:width="100dp"
android:gravity="center|left|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView5"
android:gravity="center|top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailAddress" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout4"
android:layout_marginTop="5dp"
android:gravity="top">
<TextView
android:text="Description"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView6"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView7"
android:gravity="center|top" />
<EditText
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailDescription" />
</LinearLayout>
</LinearLayout>
<TextView
android:text="Registered User"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView8"
android:layout_marginTop="10dp"
android:gravity="center" />
<android.support.v7.widget.RecyclerView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="#+id/recyclerViewLocationUser"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/progressBarLocationDetail"
android:layout_marginTop="20dp" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="50dp"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff03a9f4"
android:layout_gravity="right"
android:gravity="center">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Is there something I can do?
Thanks in advance :)
Use this xaml file & compare with your file so that you will get idea what mistake you was making
I realize the issue was using android:gravity (in second & third LinearLayout) along with android:weight which was pushing your layout toward top.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/main_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="610.3dp">
<TextView
android:text="Location Detail"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView9"
android:layout_marginTop="0dp"
android:gravity="center" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="199.3dp"
android:id="#+id/linearLayout1"
android:layout_marginTop="0dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout2">
<TextView
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailName" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout3"
android:layout_marginTop="5dp">
<TextView
android:text="Address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView4"
android:width="100dp"
android:gravity="center|left|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView5"
android:gravity="center|top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailAddress" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout4"
android:layout_marginTop="5dp"
android:gravity="top">
<TextView
android:text="Description"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView6"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView7"
android:gravity="center|top" />
<EditText
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailDescription" />
</LinearLayout>
</LinearLayout>
<TextView
android:text="Registered User"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView8"
android:layout_marginTop="10dp"
android:gravity="center" />
<android.support.v7.widget.RecyclerView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="#+id/recyclerViewLocationUser"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/progressBarLocationDetail"
android:layout_marginTop="20dp" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="50dp"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff03a9f4"
android:layout_gravity="right"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
I don't know why, but my layout color just stops in the bottom of the screen.
I don't think my code is doing that.
And, by the way, does anyone know where to get ideas from a simple layout like this? TextViews and EditTexts?
Mine looks awful
<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"
android:background="#color/AMOB_gray"
tools:context="com.example.tiagosilva.amob_android.TubeDataFragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center"
android:background="#color/AMOB_gray">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/material"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/snipperMaterial">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/diameter"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp" />
<EditText
android:id="#+id/et_diameter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/thickness"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp"
android:gravity="center"/>
<EditText
android:id="#+id/et_thickness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/clr"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp"
android:gravity="center"/>
<EditText
android:id="#+id/et_clr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<Button
android:id="#+id/btn_save_tube"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round_buttons"
android:text="#string/save"
android:textColor="#color/AMOB_gray"
android:layout_marginTop="10dp"/>
</LinearLayout>
</ScrollView>
Instead of this:
<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"
tools:context="com.example.tiagosilva.amob_android.TubeDataFragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center"
android:background="#color/AMOB_gray">
Try this
<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"
tools:context="com.example.tiagosilva.amob_android.TubeDataFragment"
android:background="#color/AMOB_gray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center">
So to move the background color inside the root ViewGroup
Add below line in your scroll view. This will do what you want
android:fillViewport="true"
I'm trying to make a listView with progress bar exactly like the image below
I'm use android:layout_toRightOf to display the progressBar beside the Pro-XXX-XXX, but it display below the text .
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:id="#+id/ListProject"
android:textStyle="bold"
android:textColor="#color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ProgressBar
android:id="#+id/downloadProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/ListProject" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blue"
android:id="#+id/ListTimeIn"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blue"
android:layout_toLeftOf="#+id/ListTimeIn"
android:id="#+id/ListTimeOut"/>
<TextView android:id="#+id/ListDescription"
android:layout_width="wrap_content"
android:textColor="#color/blue"
android:layout_height="wrap_content"/>
</LinearLayout>
Change to RelativeLayout
#Chintan answer
You need to use the tools provided with the Relative Layout.
Your ProgressBar needs to be "toRightOf" as well as "toEndOf" the TextView:
<?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="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp">
<TextView
android:id="#+id/ListProject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="20dp"
android:paddingRight="20dp"
android:text="Test"
android:textColor="#color/black"
android:textStyle="bold"/>
<ProgressBar
android:id="#+id/downloadProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/ListProject"
android:layout_toRightOf="#+id/ListProject"/>
</RelativeLayout>
<TextView
android:id="#+id/ListTimeIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
<TextView
android:id="#+id/ListTimeOut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"/>
<TextView
android:id="#+id/ListDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"/>
</LinearLayout>
I have just tested this xml, and it works perfectly well.
put following code
<?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="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/ListProject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HProxx -cxcscdc"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/downloadProgressBar"
android:textColor="#color/black"
android:textStyle="bold" />
<ProgressBar
android:id="#+id/downloadProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<TextView
android:id="#+id/ListTimeIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HProxx -cxcscdc"
android:textColor="#CADFFF" />
<TextView
android:id="#+id/ListTimeOut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/ListTimeIn"
android:text="HProxx -cxcscdc"
android:textColor="#CADFFF" />
<TextView
android:id="#+id/ListDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HProxx -cxcscdc"
android:textColor="#CADFFF" />
</LinearLayout>
Replace your xml with xml below.
<?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="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/ListProject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="2"
android:textColor="#color/black"
android:textStyle="bold" />
<ProgressBar
android:id="#+id/downloadProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:id="#+id/ListTimeIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blue" />
<TextView
android:id="#+id/ListTimeOut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/ListTimeIn"
android:textColor="#color/blue" />
<TextView
android:id="#+id/ListDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blue" />
</LinearLayout>
Let me know if this works for you.
Can anyone help me with placing my undertitle right under the title?
I'm relatively new to android programming and sorry for my bad english :D
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/listIcon"
android:padding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/facebook"/>
<TextView
android:id="#+id/listText"
android:layout_gravity="center_vertical"
android:padding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:id="#+id/listTextDescription"
android:layout_gravity="center_vertical"
android:padding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Undertitle" />
</LinearLayout>
Try this, just change your layout from LinearLayout to RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="#+id/listIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="8dp"
android:src="#drawable/facebook" />
<TextView
android:id="#+id/listText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toRightOf="#+id/listIcon"
android:padding="8dp"
android:text="Title" />
<TextView
android:id="#+id/listTextDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toRightOf="#+id/listText"
android:padding="8dp"
android:text="Undertitle" />
</RelativeLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/listIcon"
android:padding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/facebook"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/listText"
android:layout_gravity="center_vertical"
android:padding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:id="#+id/listTextDescription"
android:layout_gravity="center_vertical"
android:padding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Undertitle" />
</LinearLayout>
</LinearLayout>