how to place circular image-view on layout? - android

Here is what I'm trying to achieve :
But i ended up creating something like this :
How do i get circular edge to the imageview ? Note that layout containing text have overlapped imageview as well.
Here is my layout file :
<?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="#drawable/background"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/background"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="120dp"
android:layout_height="125dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:background="#color/accent_white"
android:id="#+id/vendoravatar_imageview"
android:src="#drawable/avatarnotfound" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="center"
android:id="#+id/data_layout"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<View
android:layout_width="100dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/accent_white"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:typeface="serif"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:text="#string/random_vendoruser1"
android:id="#+id/vendorusername_textview"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginLeft="10dp"
android:typeface="serif"
android:text="#string/random_vendoruser1"
android:id="#+id/vendoruserdesc_textview"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:id="#+id/editvuser_imageview"
app:srcCompat="#drawable/ic_pencil"/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_marginLeft="20dp"
android:background="#color/client_grey"
></View>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:id="#+id/deletevuser_imageciew"
app:srcCompat="#drawable/ic_dustbin_color"/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:background="#color/client_grey"
></View>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:id="#+id/lockvuser_imageview"
app:srcCompat="#drawable/ic_lock_open_24dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
Please help, thanks in advance. I'm just addings some text to avoid mostly code error from stackoverflow.

Try this Remove android:background="#color/accent_white" from your CircleImageView
<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="#color/colorAccent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="120dp"
android:layout_height="125dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:id="#+id/vendoravatar_imageview"
android:src="#drawable/nilesh" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="center"
android:id="#+id/data_layout"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<View
android:layout_width="100dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="accent_white"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:typeface="serif"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:text="random_vendoruser1"
android:id="#+id/vendorusername_textview"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginLeft="10dp"
android:typeface="serif"
android:text="random_vendoruser1"
android:id="#+id/vendoruserdesc_textview"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:id="#+id/editvuser_imageview"
app:srcCompat="#drawable/ic_delete"/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_marginLeft="20dp"
android:background="#color/colorAccent"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:id="#+id/deletevuser_imageciew"
app:srcCompat="#drawable/ic_close"/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:background="#color/colorAccent"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:id="#+id/lockvuser_imageview"
app:srcCompat="#drawable/ic_add_black_24dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
OUTPUT
EDIT
<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:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:layout_marginLeft="-20dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:background="#color/colorAccent"
android:layout_toEndOf="#id/vendoravatar_imageview"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/data_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginLeft="20dp"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="accent_white"
android:orientation="vertical">
<TextView
android:id="#+id/vendorusername_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="random_vendoruser1"
android:textSize="16sp"
android:typeface="serif" />
<TextView
android:id="#+id/vendoruserdesc_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="random_vendoruser1"
android:textSize="14sp"
android:typeface="serif" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/editvuser_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
app:srcCompat="#drawable/ic_delete" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:background="#color/colorAccent" />
<ImageView
android:id="#+id/deletevuser_imageciew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
app:srcCompat="#drawable/ic_close" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:background="#color/colorAccent" />
<ImageView
android:id="#+id/lockvuser_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
app:srcCompat="#drawable/ic_add_black_24dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/vendoravatar_imageview"
android:layout_width="120dp"
android:layout_height="125dp"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:src="#drawable/nilesh" />
</RelativeLayout>
OUTPUT

To make a circular ImageView add CircularImageView in your layout XML
and add CircularImageView library in your project or you can also grab
it via Gradle:
implementation 'com.mikhaellopez:circularimageview:3.2.0'
and then use this in xml where you want that circular image
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="#drawable/image"
app:civ_border_color="#EEEEEE"
app:civ_border_width="4dp"
app:civ_shadow="true"
app:civ_shadow_radius="10"
app:civ_shadow_color="#8BC34A"/>

Related

Android: Imageview getting resized while the height of the object above is altered

Here is my layout XML
<?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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.homerevise.studyapp.activity.HomeScreenActivity"
tools:showIn= "#layout/app_bar_main">
<RelativeLayout
android:id="#+id/rel_colour"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#drawable/path_background">
<ImageView
android:id="#+id/image_more"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="25dp"
android:background="#drawable/more"/>
<TextView
android:id="#id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="90dp"
android:textColor="#000"
android:textSize="24sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/image_page_title"
android:layout_width="240dp"
android:layout_height="120dp"
android:layout_below="#id/txtName"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:background="#drawable/page_title" />
<ImageView
android:id="#+id/image_happy_student"
android:layout_width="120dp"
android:layout_height="165dp"
android:layout_alignEnd="#id/image_page_title"
android:layout_alignRight="#id/image_page_title"
android:layout_alignParentRight="true"
android:layout_marginTop="75dp"
android:layout_marginRight="20dp"
android:background="#drawable/happy_student" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="#+id/image_subject_title"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:background="#drawable/subject_title" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_below="#id/image_subject_title"
android:orientation="horizontal" />
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<TextView
android:id="#+id/txtRecentlyLearned"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:layout_below="#id/recyclerView"
android:text="Recently Learned"
android:textColor="#2A3E61"
android:textSize="24sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/image_Recently_Learned"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/txtRecentlyLearned"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:src="#drawable/recently_learned"
android:layout_marginBottom="90dp"/>
</RelativeLayout>
</LinearLayout>
If the layout height of the recycler view changes the imageview txtRecentlyLearned gets reseized. It becomes too small. Like even if the height of the recycler view is changed to 250dp the image size drops considerably. The Imageview should not get resized at all ever.
How do I fix this?
Thank you.
Move textView and imageView outside the RelativeLayout to the parent LinearLayout and add android:layout_weight="1" to the RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="0dp">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<TextView
android:id="#+id/txtRecentlyLearned"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="#+id/image_Recently_Learned"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/recently_learned" />
</LinearLayout>
I Played around a little with the layout weight and relative views for now it seems to work.
<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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.homerevise.studyapp.activity.HomeScreenActivity"
tools:showIn= "#layout/app_bar_main">
<RelativeLayout
android:id="#+id/rel_colour"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:background="#drawable/path_background">
<ImageView
android:id="#+id/image_more"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="25dp"
android:background="#drawable/more"/>
<TextView
android:id="#id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="90dp"
android:textColor="#000"
android:textSize="24sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/image_page_title"
android:layout_width="240dp"
android:layout_height="120dp"
android:layout_below="#id/txtName"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:background="#drawable/page_title" />
<ImageView
android:id="#+id/image_happy_student"
android:layout_width="120dp"
android:layout_height="165dp"
android:layout_alignEnd="#id/image_page_title"
android:layout_alignRight="#id/image_page_title"
android:layout_alignParentRight="true"
android:layout_marginTop="75dp"
android:layout_marginRight="20dp"
android:background="#drawable/happy_student" />
<ImageView
android:id="#+id/image_subject_title"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="300dp"
android:background="#drawable/subject_title" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_below="#id/image_subject_title"
android:orientation="horizontal" />
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="#+id/txtRecentlyLearned"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:text="Recently Learned"
android:textColor="#2A3E61"
android:textSize="24sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/image_Recently_Learned"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/txtRecentlyLearned"
android:src="#drawable/recently_learned"
/>
</RelativeLayout>
</LinearLayout>

Fragment layout is not scrolling above keyboard when soft keyboard pop ups

I have one fragment whose layout i want to show above keyboard when softkeyboard opens up. The layout is:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#drawable/ic_bg_splash"
android:fitsSystemWindows="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="#+id/previous"
android:layout_width="37.5dp"
android:layout_height="37.5dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="22dp"
android:background="#drawable/left"
android:padding="7dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="12dp">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="7dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="7dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="7dp"
android:orientation="vertical">
<ImageView
android:id="#+id/subCat"
android:layout_width="157.5dp"
android:layout_height="157.5dp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="50dp"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="12dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito"
android:paddingLeft="20dp"
android:text="#string/enter_answer"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
<LinearLayout
android:layout_width="262.5dp"
android:layout_height="52.5dp"
android:layout_marginTop="7dp"
android:background="#drawable/answer_bg"
android:orientation="horizontal">
<EditText
android:id="#+id/answer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="8"
android:background="#null"
android:fontFamily="#font/nunito"
android:inputType="textNoSuggestions"
android:maxLines="1"
android:padding="7dp"
android:textColor="#android:color/white"
android:textSize="15sp" />
<ImageView
android:id="#+id/wrong_answer"
android:layout_width="27.5dp"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:src="#drawable/red_cross"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:layout_marginBottom="27dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito"
android:text="#string/reset"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="14.3sp" />
<TextView
android:id="#+id/submit_ans"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:background="#drawable/white_rounded"
android:fontFamily="#font/nunito_semibold"
android:paddingLeft="17dp"
android:paddingTop="7dp"
android:paddingRight="17dp"
android:paddingBottom="7dp"
android:text="#string/submit"
android:textAllCaps="true"
android:textColor="#color/lineColor"
android:textSize="14.3sp" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="#+id/next"
android:layout_width="37.5dp"
android:layout_height="37.5dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="22dp"
android:background="#drawable/right" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/write_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
android:elevation="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/write_success"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="10dp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I have tried by setting windowssoftinputmode to adjustResize in manifest and also using fitsystemwindows to true in the fragment parent layout but still it is not working and using scrollview as parent layout instead of relativelayout. So please suggest me any workaround for this issue.
Edit: Added below activity.xml layout:
Below is the host activity layout:
<?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="match_parent"
android:layout_height="match_parent"
android:background="#drawable/language_bg"
android:orientation="vertical"
tools:context=".home.HomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bottom_rounded">
<RelativeLayout
android:id="#+id/taskBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_weight="1.7"
android:paddingLeft="30dp"
android:paddingTop="5dp">
<ImageView
android:layout_width="143dp"
android:layout_height="56dp"
android:layout_gravity="left|center_vertical"
android:src="#drawable/hello_logo" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/learn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="33dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:src="#drawable/learn_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/learn"
android:textColor="#color/lineColor"
android:textSize="11sp" />
<View
android:id="#+id/learn_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="#color/lineColor" />
</LinearLayout>
<LinearLayout
android:id="#+id/practice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="42dp"
android:layout_height="28dp"
android:src="#drawable/practice_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/practice"
android:textColor="#color/lineColor"
android:textSize="11sp" />
<View
android:id="#+id/practice_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="#color/lineColor"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:layout_marginRight="30dp"
android:layout_weight="1.3"
android:gravity="right"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/unlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="26.5dp"
android:layout_height="32dp"
android:src="#drawable/unlock_blue" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/unlock"
android:textColor="#color/lineColor"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:gravity="center_horizontal|bottom"
android:orientation="vertical">
<ImageView
android:layout_width="33dp"
android:layout_height="30dp"
android:layout_marginTop="2dp"
android:src="#drawable/language" />
<TextView
android:id="#+id/language_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="#string/lang"
android:textAllCaps="true"
android:textColor="#color/lineColor"
android:textSize="11dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/appbar_practice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="12dp"
android:visibility="gone">
<LinearLayout
android:id="#+id/read_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="23.5dp"
android:layout_height="17.5dp"
android:background="#drawable/icon_read" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/read"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/read_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/speak_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="16.5dp"
android:layout_height="21.5dp"
android:background="#drawable/icon_speak" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/speak"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/speak_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/listen_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="18.5dp"
android:layout_height="18.5dp"
android:background="#drawable/icon_listen" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/listen"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/listen_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/write_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="17dp"
android:layout_height="19dp"
android:background="#drawable/icon_write" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/write"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/write_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Try to put your scrollView into relative Layout.
After commenting this from my activity onCreate() it started working:
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)

Android 3.0.1 editor not the same with what is rendered on device

I am using android 3.0.1. I have been testing my app using Memu emulator. Everything was fine until I tested on android device and views did not fit on the screen. This is a screenshot what appears on the device which is a small samsung phone.
and this is what is in the android studio editor
Here is my xml
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.example.user.eafya.activities.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/linearmain1"
android:layout_height="240dp"
android:background="#drawable/blackbg"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wallet Balance: 4,500"
android:textColor="#ffff"
android:layout_gravity="end"/>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/patient_profile_pic"
android:layout_width="80dp"
android:layout_height="100dp"
android:layout_gravity="center|center_horizontal"
android:layout_marginTop="50dp"
android:background="#drawable/itemsbg"
android:src="#drawable/me"
app:civ_border_width="1dp"
app:civ_border_color="#fc0303"/>
<TextView
android:id="#+id/patient_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Francis Kamau"
android:textColor="#color/material_purple_50"
android:textSize="25sp" />
<TextView
android:id="#+id/patient_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Ke-q980-sy"
android:textColor="#color/material_purple_50"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearmain2"
android:layout_below="#+id/linearmain1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:background="#drawable/blackbgedit"
android:orientation="horizontal"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="8dp">
<TextView
android:id="#+id/totalvisitslabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Total Visits"
android:textColor="#color/material_deep_purple_50"
android:textSize="16sp" />
<TextView
android:id="#+id/totalvisitsreal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="4"
android:textColor="#color/material_deep_purple_50"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="50dp"
android:background="#666666"
></View>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="8dp">
<TextView
android:id="#+id/nextappointmentlabel"
android:paddingLeft="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Next Appointment"
android:textColor="#color/material_deep_purple_50"
android:textSize="16sp" />
<TextView
android:id="#+id/nextappointmentreal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="09/09/2017"
android:textColor="#color/material_deep_purple_50"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="horizontal"
android:background="#666666"
android:layout_below="#id/linearmain2"
>
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearmain3"
android:layout_below="#id/linearmain2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#drawable/blackbgedit"
android:orientation="horizontal">
//This has circular image views of diffrent items in the first row
//block [1,1]
<LinearLayout
android:paddingTop="25dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/appointment"
android:onClick="goToAppointment"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="40dp"
android:layout_gravity="center|center_vertical"
android:background="#drawable/itemsbg"
android:src="#drawable/appointment"
app:civ_border_width="1dp"
app:civ_border_color="#fc0303"/>
<TextView
android:id="#+id/patient_appointment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Appointments"
android:textColor="#color/material_purple_50"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:visibility="visible"
android:background="#666666"
></View>
//block[1,2]
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="25dp"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center|center_horizontal"
android:layout_marginTop="40dp"
android:background="#drawable/itemsbg"
android:src="#drawable/user_icon"
app:civ_border_width="1dp"
app:civ_border_color="#fc0303"/>
<TextView
android:id="#+id/patient_clinical_history"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Clinical History"
android:textColor="#color/material_purple_50"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="#666666"
></View>
//block[1,3]
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="25dp">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/pic_allergies"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center|center_horizontal"
android:layout_marginTop="40dp"
android:background="#drawable/itemsbg"
android:src="#drawable/allergy"
android:onClick="goToAllergies"
app:civ_border_width="1dp"
app:civ_border_color="#fc0303"/>
<TextView
android:id="#+id/patient_allergies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Allergies"
android:textColor="#color/material_purple_50"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="horizontal"
android:background="#666666"
>
</View>
//This is where the second row of main items starts
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#drawable/blackbgedit"
android:orientation="horizontal">
//block[2,1]
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="25dp">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/pic_wallet"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center|center_horizontal"
android:layout_marginTop="40dp"
android:background="#drawable/itemsbg"
android:src="#drawable/wallet1"
android:onClick="goToWallet"
app:civ_border_width="1dp"
app:civ_border_color="#fc0303"/>
<TextView
android:id="#+id/patient_wallet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Wallet"
android:textColor="#color/material_purple_50"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="#666666"
></View>
//block[2,2]
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="25dp">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/pic_ambulance"
android:layout_width="56dp"
android:layout_height="57dp"
android:layout_gravity="center|center_horizontal"
android:layout_marginTop="40dp"
android:background="#drawable/itemsbg"
android:src="#drawable/ambulance1"
app:civ_border_color="#fc0303"
app:civ_border_width="1dp" />
<TextView
android:id="#+id/patient_ambulance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Ambulance"
android:textColor="#color/material_purple_50"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="#666666"
></View>
//block[2,3]
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="25dp">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/pic_tips"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center|center_horizontal"
android:layout_marginTop="40dp"
android:background="#drawable/itemsbg"
android:src="#drawable/tips1"
app:civ_border_width="1dp"
app:civ_border_color="#fc0303"/>
<TextView
android:id="#+id/patient_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="2dp"
android:text="Medical Tips"
android:textColor="#color/material_purple_50"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
For each of your boxes under linearmain3 etc:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center" <---- this will center the content in the boxes, regardless of how tall or short they are
android:background="#drawable/blackbgedit"
android:orientation="horizontal">
<LinearLayout
android:paddingTop="25dp" <--- take this line out
android:layout_width="0dp"
android:layout_height="wrap_content" <--- change from match_parent
android:layout_weight="1"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView ...
You might find that because you hard-coded the height of linearmain1 that is still doesn't look that great. I would suggest using a layout_weight to make it look better on different screen sizes.
The problem was on the parent linear layoutt where we have this line;
android:background="#drawable/blackbg"
this drawable item is an xml that has a large height and pushes everything else off the screen.

Error parsing XML:no element found - How can I fix this bug?

Please help me fix these bugs, I was making a app these errors are coming while running this app,
CODE:
<?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"
tools:context="com.example.shivamx.test_splash.Home_test"
android:orientation="vertical"
android:padding="10dp"
android:background="#color/backgroundcolor">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_green"
android:padding="10dp"
android:src="#drawable/ic_inbox_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Engineering"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_yelow"
android:padding="10dp"
android:src="#drawable/ic_bba_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="BBA"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_pink"
android:padding="10dp"
android:src="#drawable/ic_bsc_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="BSc"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_purple"
android:padding="10dp"
android:src="#drawable/ic_llb_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LLB"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_blue_aboutme"
android:padding="10dp"
android:src="#drawable/ic_about_me_box_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="About Me"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="About The Creator"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
These files exist in the folder res/layouts. Still error is there. What should i do?
Please tell fast.
from the looks of it activity_home_test.xml does not exist in your res/layout/ directory.
Your code is correct You just forgot to close your parent <LinearLayout> correct it
Just close your parent </LinearLayout> like below code
<?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"
tools:context="com.example.shivamx.test_splash.Home_test"
android:orientation="vertical"
android:padding="10dp"
android:background="#color/backgroundcolor">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_green"
android:padding="10dp"
android:src="#drawable/ic_inbox_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Engineering"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_yelow"
android:padding="10dp"
android:src="#drawable/ic_bba_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="BBA"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_pink"
android:padding="10dp"
android:src="#drawable/ic_bsc_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="BSc"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_bg_purple"
android:padding="10dp"
android:src="#drawable/ic_llb_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LLB"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Study Material"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circle_blue_aboutme"
android:padding="10dp"
android:src="#drawable/ic_about_me_box_black_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="About Me"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="About The Creator"
android:textColor="#color/darkgrey"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
you have not declare root layout element in your XML or not close root element. so might you getting error. format should like below.
<rootelement>
<subelement>
.......
</subelemnt>
</rootelement>
for example:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.divyesh.friendfinder.MainActivity"
tools:showIn="#layout/app_bar_main">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Hint"
android:inputType="text"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:id="#+id/editTextusername"
android:layout_marginStart="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/editTextusername"
android:hint="Enter second user lat"
android:inputType="text"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:id="#+id/editTextlat"
android:layout_marginStart="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/editTextlat"
android:hint="Enter second user long"
android:inputType="text"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:id="#+id/editTextlong"
android:layout_marginStart="10dp" />
<TextView
android:id="#+id/textinformssssss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Click Button bellow and Start Service"/>
<Button
android:id="#+id/subbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:text="genrate location"
android:layout_below="#+id/textinformssssss"/>
</RelativeLayout>

How to make old layouts visible?

I have a layout that is shown correctly, but after adding DrawerLayout my old layouts were hidden. Here is my code after adding drawer:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="2"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include
android:id="#+id/activity_base"
layout="#layout/activity_base"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<RelativeLayout
android:id="#+id/resturantlayout"
android:layout_width="0dp"
android:layout_marginTop="10dp"
android:layout_marginRight="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#bd4304">
<TextView
android:text="رستوران"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtresturant"
android:textSize="18sp"
android:textStyle="normal|bold"
android:layout_centerHorizontal="true"
android:layout_below="#+id/imageButtonresturant" />
<ImageButton
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:background="#drawable/resturantlogo"
android:id="#+id/imageButtonresturant"
android:scaleType="fitXY"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/coffeshoplayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp"
android:background="#d2ae6d">
<ImageButton
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:background="#drawable/cofeelogo"
android:id="#+id/imageButtencofee"
/>
<TextView
android:text="کافه ها"
android:layout_marginTop="13dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textViewcofee"
android:textStyle="normal|bold"
android:textSize="18sp"
android:layout_below="#+id/imageButtencofee"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/servfoodlayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:background="#f58634">
<ImageButton
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:background="#drawable/ghazalogo"
android:id="#+id/imageButtonghaza" />
<TextView
android:text="غذای آماده"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="normal|bold"
android:textSize="18sp"
android:id="#+id/textViewgghaza"
android:layout_below="#+id/imageButtonghaza"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="10dp"
android:background="#7db446">
<TextView
android:text="فست فود"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginTop="10dp"
android:textStyle="normal|bold"
android:textSize="18sp"
android:layout_below="#+id/imageButtonfastfood"
android:layout_centerHorizontal="true" />
<ImageButton
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:background="#drawable/fastfoodlogo"
android:id="#+id/imageButtonfastfood"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<FrameLayout
android:id="#+id/drawer_frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginLeft="56dp"
android:choiceMode="singleChoice"
android:dividerHeight="1dp" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
The ids of two old layouts are: "cofeeshoprow, servfoodlayout" that they were shown correct.
I should have used android:layout_below="#+id/activity_base" for the layouts which should be shown below the "activity_base". Generally in this cases try to match layouts using "android:layout_below".

Categories

Resources