Unable to align text to right of imageview android layout xml - android

I am trying to create layout like below in android:
But my problem is I am unable to add textbelow the image or on the right hand side of imageview. If I wrap ImageView and textview in a LinearLayout the then the whole view shrinks. Should I be using TableLayout?
My current layout xml is like below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_below="#id/my_recycler_view"
android:layout_margin="30dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:layout_weight="1"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vwImageAndClassroom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/img_room"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/coverimage_contentdescription"
android:scaleType="fitCenter"
android:src="#drawable/comm_book_icon"
/>
<TextView
android:id="#+id/tv_emp_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="12dp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_below="#id/img_room"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:text="TEXT 1"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:layout_weight="1"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vwImageAndClassroom2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/img_room2"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/coverimage_contentdescription"
android:scaleType="fitCenter"
android:src="#drawable/visitor_book_icon"
/>
<TextView
android:id="#+id/tv_emp_name2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="12dp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_below="#id/img_room2"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:text="TEXT 2"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:layout_weight="1"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vwImageAndClassroom3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/img_room3"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/coverimage_contentdescription"
android:scaleType="fitCenter"
android:src="#drawable/visitor_book_icon"
/>
<TextView
android:id="#+id/tv_emp_name3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="12dp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_below="#id/img_room3"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:text="TEXT 3"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>

Hope this will help you and you will find your solutions from this xml code. I just modify some of your code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="#android:drawable/ic_search_category_default"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This Right side text 1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="#android:drawable/ic_search_category_default"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This Right side text 1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="#android:drawable/ic_search_category_default"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This Right side text 1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is under layout text"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is under layout text"/>
</LinearLayout>
</LinearLayout>

Have placeholder views where text is not required.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/next_green" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/next_green" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/next_green" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="text"/>
</LinearLayout>
</LinearLayout>

I did exactly what you want
Open image
<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:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#android:drawable/btn_dialog" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView3"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#android:drawable/btn_dialog" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#android:drawable/btn_dialog" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="15dp"
android:text="Some text" />
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="15dp"
android:text="Some text" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView7"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Some text"
app:srcCompat="#android:drawable/btn_dialog" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/textView8"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Some text"
app:srcCompat="#android:drawable/btn_dialog" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/textView9"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Some text"
app:srcCompat="#android:drawable/btn_dialog" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

Related

When TextView expanded below linerview is disappear

I have a problem when my TextView expanded with many texts the items below the TextView is disappeared.
I am talking about the TextView with ID: tvPostBody
I added ScrolleView to make sure the text will display completely if the text is more than max lines of TextView
Here is my XML file code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
tools:context="com.atjt.login.DisplayOnePost">
<LinearLayout
android:layout_width="368dp"
android:layout_height="495dp"
android:orientation="vertical"
tools:layout_editor_absoluteX="3dp"
tools:layout_editor_absoluteY="-2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/ivUserImage"
android:layout_width="108dp"
android:layout_height="127dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dp"
android:layout_weight="0.13"
android:cropToPadding="true"
android:padding="1dp"
android:scaleType="centerCrop"
app:srcCompat="#mipmap/no_image" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/tvUserFullName"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="User Full Name"
android:textAlignment="viewEnd" />
<TextView
android:id="#+id/tvPostTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:lineSpacingExtra="8sp"
android:text="Post Title in Full"
android:textColor="#android:color/background_dark"
android:textDirection="rtl"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="#+id/tvPostBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="TextView" />
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<TextView
android:id="#+id/tvNumberOfReplies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="0" />
<TextView
android:id="#+id/tvReply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Reply" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="|" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tvNumberOfViews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="0" />
<TextView
android:id="#+id/tvViews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Views" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="105dp"
android:layout_weight="1"
android:text="15-12-2017" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Any suggestions,
Problem is
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
Here, height is specified as wrap_content and therefore, it may fill entire below area and view below it may not be visible.
You need to specify some height for this so that you views below it are always visible.

i am getting issue for screen sizes 5.5 or above

my xml layout is working fine, everything coming in single screen no need to scroll in below 5.5 screens
but in 5.5 not able to see all thing in single screen i have to scroll to see remaining content that is two buttons showing bottom `
This is the screenshot.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/layout_container"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/left_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:src="#drawable/left_arrow" />
<TextView
android:id="#+id/date_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="5"
android:gravity="center_horizontal"
android:paddingLeft="60dp"
android:paddingRight="60dp"
android:text="Monday, 24 August, 2015"
android:textColor="#color/White" />
<ImageView
android:id="#+id/right_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:src="#drawable/right_arrow" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/morning_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/morning_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/morning_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/morning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Morning"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/noon_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/noon_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/noon_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/noon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Noon"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/evening_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:paddingBottom="6dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/evening_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/evening_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/evening"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Evening"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/night_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/night_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/night_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/night"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Night"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/pillbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="#drawable/pill_box_icon" />
<TextView
android:id="#+id/pill_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pill Box"
android:textColor="#color/White"
android:textSize="13dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="right"
android:orientation="vertical">
<ImageView
android:id="#+id/plus_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/plus_icon" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

Showing Loading Bar lib

Hi there I am trying to use this lib into my app
https://github.com/jlmd/AnimatedCircleLoadingView
I want it to on top of that layout, can someone please show me ho it is done?
I trying adding it but it either covered the whole screen or it would occupy a part of layout completly
layout
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="#color/postBg"
android:orientation="vertical"
tools:ignore="ContentDescription">
<include
android:id="#+id/app_bar"
layout="#layout/app_bar"/>
<LinearLayout
android:id="#+id/newStatusHeader"
style="#style/newStatusHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/postOwnerImage"
android:layout_width="60dp"
android:layout_height="60dp"/>
<LinearLayout
android:id="#+id/headerInfoContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:padding="#dimen/postsItemMargin">
<TextView
android:id="#+id/postOwnerName"
style="#style/postOwnerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="#+id/postPrivacy"
style="#style/postPublishDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/publicPrivacy"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E9E9E9"/>
<LinearLayout
android:id="#+id/newStatusBody"
style="#style/newStatusBody"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical">
<ImageView
android:id="#+id/imagePreview"
android:layout_width="match_parent"
android:layout_height="170dp"
android:scaleType="centerCrop"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/circle_loading_view"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true"
app:mainColor="#color/primaryColor"
app:secondaryColor="#color/primaryColorDark"
android:layout_gravity="top" />
</LinearLayout>
<EditText
android:id="#+id/statusEdittext"
style="#style/statusEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="top|left"
android:hint="#string/urStatus"
android:inputType="textMultiLine"
android:padding="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/placePreviewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="#drawable/ic_place_black"/>
<TextView
android:id="#+id/placeValuePreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Rue Ibn ElArabi, Agadir 80000, Morocco"
android:textColor="#color/primary_high_light"/>
<TextView
android:id="#+id/removePlace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:textStyle="bold"
android:textColor="#android:color/holo_red_light"
android:text="X"/>
</LinearLayout>
<LinearLayout
android:id="#+id/urlPreviewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="#drawable/ic_insert_link_black"/>
<TextView
android:id="#+id/urlValuePreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="https://www.atouchlab.com"
android:textColor="#color/primary_high_light"/>
<TextView
android:id="#+id/removeLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:textStyle="bold"
android:textColor="#android:color/holo_red_light"
android:text="X"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E9E9E9"/>
<LinearLayout
android:id="#+id/newStatusFooter"
style="#style/newStatusFooter"
android:layout_width="match_parent"
android:layout_height="65dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_weight="1">
<ImageButton
android:id="#+id/addPhoto"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_camera_button"
android:layout_gravity="center" />
<ImageButton
android:id="#+id/addPlace"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_place_button"
android:layout_gravity="center" />
<ImageButton
android:id="#+id/addLink"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_insert_link_button"
android:layout_gravity="center" />
<ImageButton
android:id="#+id/changePrivacy"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_privacy_button"
android:layout_gravity="center" />
</LinearLayout>
<ImageButton
android:id="#+id/sendStatus"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_publish_button"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
lib layout
<com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/circle_loading_view"
android:layout_width="250dp"
android:layout_height="250dp"
android:background="#color/background"
android:layout_centerInParent="true"
app:mainColor="#color/main_color"
app:secondaryColor="#color/secondary_color"
/>
Your problem can be solved using an relative layout that wraps the view where you want the LoadingView to be on top of, ex:
<RelativeLayout>
<com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/circle_loading_view"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true"
app:mainColor="#color/primaryColor"
app:secondaryColor="#color/primaryColorDark"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/circle_loading_view">
//the view on top of witch the loading bar should be
</LinearLayout>
</RelativeLayout>

Android map with custom layout

I' am trying to achieve sth like this:
But the ListView is overlaps my bottom bar. What is the best way to prevent such a behaviour? As you can see in the picture there is a map under bottom bar. This bottom bar is like target/destination window in Google Maps app.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.google.android.gms.maps.MapView
android:id="#+id/map"
tools:layout="#layout/fragmentMap"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:orientation="vertical">
<EditText
android:id="#+id/mapEditT"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_alignParentTop="true"
android:gravity="center|left"
android:paddingLeft="2dp"
android:paddingRight="0dp"/>
<ListView
android:id="#+id/listVi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<ImageButton
android:id="#+id/draweR"
android:layout_width="wrap_content"
android:src="#drawable/draweR"/>
<LinearLayout
android:id="#+id/infoBox"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="40dp"
android:alpha="0.1"
android:background="#android:color/black"
android:orientation="horizontal">
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="Info"
/>
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="#id/text2"
android:text="Info/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
Use LinearLayout or RelativeLayout as top most parent instead of FrameLayout.
Here is the code snippet using LinearLayout.
<?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" >
<EditText
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</ListView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/draweR"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="#drawable/draweR"/>
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragmentMap" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100" >
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_weight="75" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_weight="25" />
</LinearLayout>
</LinearLayout>
You can mess around with the margins. I got it to look like the image you wanted.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragmentMap" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:orientation="vertical"
android:paddingBottom="160dp" >
<EditText
android:id="#+id/mapEditT"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_alignParentTop="true"
android:gravity="center|left"
android:paddingLeft="2dp"
android:paddingRight="0dp" />
<ListView
android:id="#+id/listVi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical" >
<ImageButton
android:id="#+id/draweR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/draweR" />
<LinearLayout
android:id="#+id/infoBox"
android:layout_width="match_parent"
android:layout_height="100dp"
android:alpha="0.1"
android:background="#android:color/black"
android:orientation="horizontal" >
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="Info" />
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="#id/text2"
android:text="Info" />
</LinearLayout>
</LinearLayout>

Android Button Place Image in center and text at bottom

I want to place Image in the center and text just below it in a button, I tried to set android:gravity but could not set it properly,here is the image attached:
below is my xml:
<?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"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
android:background="#drawable/background_img"
>
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_listen"
android:text="#string/listen"
android:drawableTop="#drawable/listen_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_gallery"
android:text="#string/gallery"
android:drawableTop="#drawable/gallery_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_play"
android:text="#string/play"
android:drawableTop="#drawable/play_btn"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
/>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_find"
android:text="#string/find"
android:drawableTop="#drawable/test_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
</LinearLayout>
</LinearLayout>
What is the proper way to center the image and text below it?
Many thanks in advance.
Try this its work for me
<RelativeLayout 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=".MainActivity" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="151dp"
android:onClick="onClick"
android:drawableTop="#drawable/ic_launcher"
android:text="Button" />
</RelativeLayout>
Try change the button to LinearLayout and use same onclicklistener on fakebutton
<LinearLayout
android:id="#+id/fakeButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_big_evento" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/menu_about" />
</LinearLayout>
I followed DjHacktorReborn comments and made the layout, here is the freezed one
<?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:background="#drawable/background_img"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4.1"
android:orientation="vertical" >
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="horizontal"
android:stretchColumns="*" >
<TableRow android:layout_weight="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_listen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/listen"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/main_icon_content_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/listen_btn" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/gallery"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/main_icon_schedule_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/gallery_btn" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_play"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:ellipsize="marquee"
android:paddingTop="90dp"
android:text="#string/play"
android:textStyle="bold"
android:textColor="#FFFFFF"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/play_btn" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_find"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/find"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/test_btn" />
</RelativeLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4.1"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
Here is the updated result
Thanks for the suggestions

Categories

Resources