How to draw a line over current screen? - android

i have a linear layout which is linked to an activity and i want to draw a line over it from a view class using addview but the problem is that when i add using addview then it shift the whole screen upwards. I want to draw a line at specific position without changing the layout. if this can we done by any other method that will be ok. Please help. Also tell that how to remove a Addview.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:weightSum="7"
android:background="#mipmap/untitled_3"
android:id="#+id/multiplayer_game_activity"
tools:context="com.bussiness.vidit.ticktacknoughtsandcrosses.Multiplayer_game">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_weight="1.18"
android:weightSum="3">
<TextView
android:id="#+id/reset_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/name_tv"
android:layout_alignBottom="#+id/name_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:onClick="reset"
android:text="RESET"
android:textColor="#android:color/holo_blue_bright"
android:textSize="10sp" />
<TextView
android:id="#+id/name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textColor="#android:color/white"
android:textSize="18sp"
android:layout_alignBaseline="#+id/turn_tv"
android:layout_alignBottom="#+id/turn_tv"
android:layout_toRightOf="#+id/turn_tv"
android:layout_toEndOf="#+id/turn_tv" />
<TextView
android:id="#+id/turn_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:layout_marginStart="9dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:text="TURN - "
android:textColor="#android:color/holo_purple"
android:textSize="15sp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="3"
android:layout_weight="0.87">
<ImageView
android:id="#+id/iv1"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv2"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv3"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="3"
android:layout_weight="0.68">
<ImageView
android:id="#+id/iv4"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv5"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv6"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="3"
android:layout_weight="0.80">
<ImageView
android:id="#+id/iv7"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv8"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv9"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="4">
<com.google.android.gms.ads.AdView
android:id="#+id/adView_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_home_footer"
android:layout_marginBottom="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"></com.google.android.gms.ads.AdView>
<ImageView
android:id="#+id/imageView4"
android:layout_width="75dp"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:src="#drawable/cross" />
<TextView
android:id="#+id/cross_win_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView4"
android:layout_alignStart="#+id/imageView4"
android:layout_below="#+id/imageView4"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:text="0"
android:textColor="#android:color/holo_green_light"
android:textSize="25dp" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="75dp"
android:layout_height="50dp"
android:layout_above="#+id/cross_win_tv"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:src="#drawable/circle" />
<TextView
android:id="#+id/cirle_win_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView5"
android:layout_centerHorizontal="true"
android:text="0"
android:textColor="#android:color/holo_red_light"
android:textSize="25dp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imageView4"
android:layout_marginEnd="11dp"
android:layout_marginRight="11dp"
android:text="Draws"
android:textColor="#android:color/holo_orange_light"
android:textSize="25dp" />
<TextView
android:id="#+id/draw_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_alignStart="#+id/textView4"
android:layout_below="#+id/imageView5"
android:layout_marginLeft="27dp"
android:layout_marginStart="27dp"
android:text="0"
android:textColor="#android:color/holo_orange_light"
android:textSize="25dp" />
</RelativeLayout>

I couldn't get exactly what you want. I assume that you want to draw a "1 px line". If so, you can do it like this:
<View
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="1dp" />

Related

I do not see the same in Emulator, according to Android Studio's preview or Android phone

I am learning from Udacity, I have learned so far LinearLayout and RelativeLayout. Based on this I tried to create an xml for a project. I created it according to preview from inside Android Studio Nexus 5X. Then when I run this in Emulator Nexus 5X again I see different output the project was created according to API 15. Then when I run it on my Android phone I see it as on preview. Following I will post the outcomes:
<?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"
tools:context=".MainActivity">
<ImageView
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:srcCompat="#drawable/background" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/topScore"
android:layout_width="350dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginBottom="15dp"
android:layout_weight="5">
<ImageView
android:id="#+id/topImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/topscore" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="18dp"
android:gravity="center"
android:text="0 - 0"
android:textColor="#android:color/background_light"
android:textSize="26dp" />
<ImageButton
android:id="#+id/arrowRightScore"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="30dp"
android:layout_marginRight="6dp"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<ImageButton
android:id="#+id/arrowLeftScore"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="6dp"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
</RelativeLayout>
<RelativeLayout
android:layout_width="390dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginBottom="25dp"
android:layout_weight="1">
<ImageView
android:id="#+id/row1"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/row" />
<TextView
android:id="#+id/textRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/row1"
android:layout_alignTop="#id/row1"
android:layout_alignRight="#id/row1"
android:layout_alignBottom="#id/row1"
android:layout_margin="1dp"
android:gravity="center"
android:text="SHOTS"
android:textColor="#000000"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowLeftRow1"
android:layout_width="52dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row1"
android:layout_alignRight="#+id/arrowLeftRow1"
android:layout_alignBottom="#id/row1"
android:layout_marginTop="0dp"
android:layout_marginRight="-35dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowRightRow1"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row1"
android:layout_alignBottom="#id/row1"
android:layout_alignParentRight="true"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/arrowRightRow1"
android:layout_alignTop="#id/row1"
android:layout_alignBottom="#id/row1"
android:layout_marginLeft="-45dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="390dp"
android:layout_height="0dp"
android:layout_marginBottom="25dp"
android:layout_weight="1">
<ImageView
android:id="#+id/row2"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/row" />
<TextView
android:id="#+id/textRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/row2"
android:layout_alignTop="#id/row2"
android:layout_alignRight="#id/row2"
android:layout_alignBottom="#id/row2"
android:layout_margin="1dp"
android:gravity="center"
android:text="FOULS"
android:textColor="#000000"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowLeftRow2"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row2"
android:layout_alignBottom="#id/row2"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row2"
android:layout_alignRight="#+id/arrowLeftRow2"
android:layout_alignBottom="#id/row2"
android:layout_marginTop="0dp"
android:layout_marginRight="-45dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowRightRow2"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row2"
android:layout_alignBottom="#id/row2"
android:layout_alignParentRight="true"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/arrowRightRow2"
android:layout_alignTop="#id/row2"
android:layout_alignBottom="#id/row2"
android:layout_marginLeft="-45dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="390dp"
android:layout_height="0dp"
android:layout_marginBottom="25dp"
android:layout_weight="1">
<ImageView
android:id="#+id/row3"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/row" />
<TextView
android:id="#+id/textRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/row3"
android:layout_alignTop="#id/row3"
android:layout_alignRight="#id/row3"
android:layout_alignBottom="#id/row3"
android:layout_margin="1dp"
android:gravity="center"
android:text="CORNERS"
android:textColor="#000000"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowLeftRow3"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row3"
android:layout_alignBottom="#id/row3"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row3"
android:layout_alignRight="#+id/arrowLeftRow3"
android:layout_alignBottom="#id/row3"
android:layout_marginTop="0dp"
android:layout_marginRight="-45dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowRightRow3"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row3"
android:layout_alignBottom="#id/row3"
android:layout_alignParentRight="true"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/arrowRightRow3"
android:layout_alignTop="#id/row3"
android:layout_alignBottom="#id/row3"
android:layout_marginLeft="-45dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="390dp"
android:layout_height="0dp"
android:layout_marginBottom="25dp"
android:layout_weight="1">
<ImageView
android:id="#+id/row4"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/row" />
<TextView
android:id="#+id/textRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/row4"
android:layout_alignTop="#id/row4"
android:layout_alignRight="#id/row4"
android:layout_alignBottom="#id/row4"
android:layout_margin="1dp"
android:gravity="center"
android:text="OFFSIDES"
android:textColor="#000000"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowLeftRow4"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row4"
android:layout_alignBottom="#id/row4"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row4"
android:layout_alignRight="#+id/arrowLeftRow4"
android:layout_alignBottom="#id/row4"
android:layout_marginTop="0dp"
android:layout_marginRight="-45dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
<ImageButton
android:id="#+id/arrowRightRow4"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignTop="#id/row4"
android:layout_alignBottom="#id/row4"
android:layout_alignParentRight="true"
android:background="#android:color/transparent"
android:src="#android:drawable/arrow_up_float" />
<TextView
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/arrowRightRow4"
android:layout_alignTop="#id/row4"
android:layout_alignBottom="#id/row4"
android:layout_marginLeft="-45dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="18dp" />
</RelativeLayout>
<Button
android:id="#+id/buttonReset"
android:layout_width="150sp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_margin="50dp"
android:layout_marginBottom="5dp"
android:layout_weight="0.5"
android:background="#drawable/reset"
android:text="RESET"
android:textColor="#cdc2b1"
android:textSize="16sp" />
</LinearLayout>
</RelativeLayout>
What I get from preview:
What I get from Emulator:
What I get from my Android Phone:
I found that I have used on top
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
That pushed 10dp the layout inside. Then I used static 390dp in RelativeLayout and that probably pushed outside the image living the arrows out of place.
<RelativeLayout
android:layout_width="390dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginBottom="25dp"
android:layout_weight="1">
By removing android:layout_margin="10dp" from top LinearLayout it looked fine now in Android's Studio emulator also! So in case you see similar problem check margins in parent Layouts

Relative Layout GridView inside of ScrollView Android

I've a feeling I am doing this totally incorrect but I know stack overflow loves an attempt. I am trying to make my whole view scrollable and the icons in my grid view will scroll with my whole view, right now just the icons scroll. I am unsure where to even start with this. I will attach my layout file onto this. I want it to look like below but be a full scrollable view right now only the icons at the bottom scroll.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView>
<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:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.curtisboylan.myapplication.SearchScreen"
android:background="#color/grey2">
<ImageView
android:id="#+id/imageView9"
android:layout_below="#+id/editText"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_width="400dp"
android:layout_marginTop="185dp"
android:background="#android:color/white"
android:layout_height="60dp" />
<ImageView
android:id="#+id/imageView7"
android:layout_below="#+id/editText"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_width="400dp"
android:layout_marginTop="115dp"
android:background="#android:color/white"
android:layout_height="60dp" />
<ImageView
android:id="#+id/imageView5"
android:layout_below="#+id/editText"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_width="400dp"
android:background="#android:color/white"
android:layout_marginTop="15dp"
android:layout_height="90dp" />
<!-- DataPicker Text Label and button -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Time Displayed Here"
android:textAlignment="center"
android:id="#+id/txt_TextDateTime"
android:textSize="30dp"
android:layout_alignTop="#+id/imageView5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="17dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click To Change Date"
android:id="#+id/btn_datePicker"
android:background="#null"
android:textAllCaps="false"
android:layout_alignBottom="#+id/imageView5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="match_parent"
android:id="#+id/button"
android:layout_x="-10dp"
android:layout_y="481dp"
android:background="#drawable/topbar"
android:layout_height="60dp"
android:text="Continue"
android:textAllCaps="false"
android:textSize="30sp"
android:textColor="#android:color/white"
android:fontFamily="sans-serif"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<GridView
android:id="#+id/gridView1"
android:layout_width="match_parent"
android:numColumns="auto_fit"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:layout_height="190dp"
android:layout_below="#+id/imageView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="16dp">
</GridView>
<TextView
android:text="What is your location?"
android:layout_x="200dp"
android:layout_y="366dp"
android:id="#+id/textView"
android:textSize="18sp"
android:layout_height="30dp"
android:layout_alignBaseline="#+id/button3"
android:layout_alignBottom="#+id/button3"
android:layout_marginLeft="48dp"
android:layout_width="275dp" />
<ImageView
android:layout_height="40dp"
app:srcCompat="#drawable/devices"
android:id="#+id/imageView8"
android:layout_width="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="125dp" />
<ImageView
android:layout_height="40dp"
app:srcCompat="#drawable/locicon1"
android:id="#+id/imageView6"
android:layout_width="22dp"
android:layout_marginTop="10dp"
android:layout_alignTop="#+id/imageView9"
android:layout_alignLeft="#+id/imageView8"
android:layout_alignStart="#+id/imageView8"
android:layout_marginLeft="5dp" />
<Button
android:id="#+id/button3"
android:background="#drawable/locationicon2"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignBottom="#+id/imageView6"
android:layout_toRightOf="#+id/textView"
android:layout_toEndOf="#+id/textView"
android:layout_marginBottom="9dp" />
<Button
android:text=""
android:background="#android:color/transparent"
android:textSize="18sp"
android:textAllCaps="false"
android:layout_width="280dp"
android:layout_height="60dp"
android:id="#+id/googleLocBtn"
android:layout_alignBaseline="#+id/textView"
android:layout_alignBottom="#+id/textView"
android:layout_toStartOf="#+id/button3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
android:hint="What is the device you wish to fix?"
android:background="#android:color/transparent"
android:layout_marginBottom="8dp"
android:layout_alignBottom="#+id/imageView8"
android:layout_toRightOf="#+id/imageView8"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_alignRight="#+id/button3"
android:layout_alignEnd="#+id/button3" />
<!-- End -->
</RelativeLayout>
</ScrollView>
Use android.support.v4.widget.NestedScrollView instead of ScrollView.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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">
<RelativeLayout
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#color/grey2">
<ImageView
android:id="#+id/imageView9"
android:layout_below="#+id/editText"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_width="400dp"
android:layout_marginTop="185dp"
android:background="#android:color/white"
android:layout_height="60dp" />
<ImageView
android:id="#+id/imageView7"
android:layout_below="#+id/editText"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_width="400dp"
android:layout_marginTop="115dp"
android:background="#android:color/white"
android:layout_height="60dp" />
<ImageView
android:id="#+id/imageView5"
android:layout_below="#+id/editText"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_width="400dp"
android:background="#android:color/white"
android:layout_marginTop="15dp"
android:layout_height="90dp" />
<!-- DataPicker Text Label and button -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Time Displayed Here"
android:textAlignment="center"
android:id="#+id/txt_TextDateTime"
android:textSize="30dp"
android:layout_alignTop="#+id/imageView5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="17dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click To Change Date"
android:id="#+id/btn_datePicker"
android:background="#null"
android:textAllCaps="false"
android:layout_alignBottom="#+id/imageView5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="match_parent"
android:id="#+id/button"
android:layout_x="-10dp"
android:layout_y="481dp"
android:background="#drawable/topbar"
android:layout_height="60dp"
android:text="Continue"
android:textAllCaps="false"
android:textSize="30sp"
android:textColor="#android:color/white"
android:fontFamily="sans-serif"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<GridView
android:id="#+id/gridView1"
android:layout_width="match_parent"
android:numColumns="auto_fit"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:layout_height="190dp"
android:layout_below="#+id/imageView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="16dp">
</GridView>
<TextView
android:text="What is your location?"
android:layout_x="200dp"
android:layout_y="366dp"
android:id="#+id/textView"
android:textSize="18sp"
android:layout_height="30dp"
android:layout_alignBaseline="#+id/button3"
android:layout_alignBottom="#+id/button3"
android:layout_marginLeft="48dp"
android:layout_width="275dp" />
<ImageView
android:layout_height="40dp"
app:srcCompat="#drawable/devices"
android:id="#+id/imageView8"
android:layout_width="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="125dp" />
<ImageView
android:layout_height="40dp"
app:srcCompat="#drawable/locicon1"
android:id="#+id/imageView6"
android:layout_width="22dp"
android:layout_marginTop="10dp"
android:layout_alignTop="#+id/imageView9"
android:layout_alignLeft="#+id/imageView8"
android:layout_alignStart="#+id/imageView8"
android:layout_marginLeft="5dp" />
<Button
android:id="#+id/button3"
android:background="#drawable/locationicon2"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignBottom="#+id/imageView6"
android:layout_toRightOf="#+id/textView"
android:layout_toEndOf="#+id/textView"
android:layout_marginBottom="9dp" />
<Button
android:text=""
android:background="#android:color/transparent"
android:textSize="18sp"
android:textAllCaps="false"
android:layout_width="280dp"
android:layout_height="60dp"
android:id="#+id/googleLocBtn"
android:layout_alignBaseline="#+id/textView"
android:layout_alignBottom="#+id/textView"
android:layout_toStartOf="#+id/button3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
android:hint="What is the device you wish to fix?"
android:background="#android:color/transparent"
android:layout_marginBottom="8dp"
android:layout_alignBottom="#+id/imageView8"
android:layout_toRightOf="#+id/imageView8"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_alignRight="#+id/button3"
android:layout_alignEnd="#+id/button3" />
<!-- End -->
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>

Android Image doesn't display on some devices

Android noob here.
I am using an image in an image view.
Image Specs: 750x500 PNG 835.36kb
It displays correctly on all device emulators and on the real device during debug. However after release it doesn't appear to show on some devices.
It's image with src 'main22' which is causing the issues.
Any help resolving this would be much appreciated!
I am using the following xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.mattblack.fibreapp.MainActivity"
android:background="#000000">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/main22"
android:layout_gravity="center_horizontal"
android:layout_above="#+id/frameLayout"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:layout_below="#+id/frameLayout6"
android:nestedScrollingEnabled="false"
android:scaleType="fitXY" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:background="#ffffff"
android:id="#+id/frameLayout"
android:layout_gravity="center_horizontal"
android:layout_above="#+id/frameLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="INACTIVE"
android:id="#+id/qjumpButton"
android:layout_gravity="center"
android:textColor="#000000"
android:background="#ffffff"
android:textSize="30sp"
android:typeface="normal"
android:onClick="clickFunction"
android:enabled="true"
android:clickable="true"
style="?android:attr/borderlessButtonStyle"
android:textStyle="normal"
android:layout_marginBottom="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Queue Jump"
android:id="#+id/textView2"
android:layout_gravity="center_horizontal|bottom"
android:textSize="20sp"
android:textColor="#e4c353"
android:layout_marginBottom="15dp" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:id="#+id/frameLayout2"
android:layout_gravity="center_horizontal"
android:layout_above="#+id/frameLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="100dp"
android:layout_height="80dp"
android:id="#+id/shakeImage"
android:layout_gravity="center"
android:src="#drawable/shake"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WINNER!"
android:id="#+id/winnerText"
android:layout_gravity="center_horizontal"
android:textColor="#ffffff"
android:textSize="30sp"
android:visibility="invisible"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1 x The Prize"
android:id="#+id/prizeText"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textSize="20sp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show at the Bar to Claim before we close."
android:id="#+id/claimText"
android:layout_gravity="center_horizontal|bottom"
android:textColor="#ffffff"
android:visibility="invisible"
android:layout_marginBottom="15dp"
android:textSize="12dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NO WIN"
android:id="#+id/nowinText"
android:layout_gravity="center_horizontal|top"
android:textColor="#ffffff"
android:textSize="40sp"
android:layout_marginTop="30dp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Try Again Tomorrow."
android:id="#+id/tryagainText"
android:layout_gravity="center_horizontal|bottom"
android:textColor="#ffffff"
android:textSize="12sp"
android:layout_marginBottom="20dp"
android:visibility="invisible" />
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/down"
android:layout_gravity="center"
android:alpha="0.1"
android:enabled="true"
android:clickable="true"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shake Again Tomorrow."
android:id="#+id/shakeTomorrowText"
android:layout_gravity="center"
android:textSize="15sp"
android:textColor="#ffffff"
android:visibility="invisible" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#ffffff"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/frameLayout3">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HOME"
android:id="#+id/button"
android:layout_gravity="left|center_vertical"
android:background="#ffffff" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CODE"
android:id="#+id/button9"
android:layout_gravity="right|center_vertical"
android:background="#ffffff"
android:onClick="profilePageClick" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_alignParentStart="false"
android:layout_alignParentTop="true"
android:background="#ffffff"
android:id="#+id/frameLayout6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FIBRE"
android:id="#+id/textView"
android:layout_gravity="center"
android:textSize="25sp"
android:textColor="#d9bc00" />
</FrameLayout>
</RelativeLayout>
I was facing the same issue. In my case the image was very large in size and that was the reason image was not showing on some device. Just reduce the image size and it will work.

How to add a layout multiple times in parent layout onClick of another layout?

I have a parent layout in which I want to add a child layout onClick of another layout. The layout I want to add it's visibility is gone right now. After clicking on NextDestination layout it shows the another layout which is LinearAddedDestination. I want to add this layout when the user clicks on NextDestination layout till 14 times after 14 times the NextDestination layout should not be visible.
How can I achieve this??
GoBoxActivity Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1.00"
android:background="#android:color/white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="DESTINATION"
android:id="#+id/textView14"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="#drawable/shape"
android:gravity="right"
android:layout_gravity="center|right"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="100dp"
android:id="#+id/LinearRemove"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_clear_black_18dp"
android:layout_marginLeft="05dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="REMOVE"
android:id="#+id/textView47"
android:layout_gravity="center"
android:layout_marginLeft="05dp"
android:textSize="14sp"
android:layout_marginRight="15dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="08dp"
android:id="#+id/imageView14"
android:background="#drawable/line2"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView10"
android:layout_marginStart="20dp"
android:background="#drawable/ic_place_black_48dp"
android:layout_marginTop="05dp"
android:layout_gravity="center" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Text_to"
android:drawableEnd="#drawable/ic_chevron_right_black_24dp"
android:layout_marginEnd="10dp"
android:text="#string/Loc"
android:layout_gravity="center"
android:layout_marginTop="05dp"
android:textAppearance="#android:style/TextAppearance.Medium"
android:cursorVisible="false"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Street/Building/Place"
android:layout_marginStart="48dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView17"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="#+id/editText_to_details"
android:layout_marginEnd="10dp"
android:hint="#string/LocationDetails"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textViewHouseDetailsTo"
android:layout_marginStart="48dp"
android:hint="#string/HouseDetails" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/LinearLayoutAdditionalContactTo">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView18"
android:layout_marginStart="20dp"
android:background="#drawable/ic_person_black_48dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/contactDetailsTo"
android:layout_marginEnd="10dp"
android:text="#string/additionalContact"
android:textAppearance="?android:attr/textAppearanceMedium"
android:drawableEnd="#drawable/ic_expand_more_black_24dp"
android:layout_marginTop="08dp"
android:layout_marginStart="05dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginEnd="50dp"
android:layout_gravity="center"
android:visibility="gone"
android:id="#+id/LinearLayoutTo"
android:layout_marginTop="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editTex"
android:layout_weight="1"
android:hint="Name"
android:layout_gravity="center"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editTe"
android:layout_weight="1"
android:hint="Phone"
android:layout_gravity="center"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/or"
android:id="#+id/textViewInputIfSender"
android:layout_gravity="center"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="220dp"
android:layout_height="40dp"
android:background="#drawable/shape"
android:layout_gravity="center_horizontal">
<ImageButton
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageButton1"
android:background="#drawable/phone2"
android:layout_gravity="center"
android:layout_marginStart="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/addFromContacts"
android:id="#+id/textView35"
android:layout_gravity="center"
android:layout_marginStart="20dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textViewInputReceiver"
android:layout_marginLeft="48dp"
android:hint="#string/contact1"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView12"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="#+id/editText_from_details"
android:layout_marginEnd="10dp"
android:hint="Instruction"
android:layout_gravity="center"
android:layout_marginLeft="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1.00"
android:background="#android:color/white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:id="#+id/LinearAddedDestination"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="DESTINATION"
android:id="#+id/textView14"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="#drawable/shape"
android:gravity="right"
android:layout_gravity="center|right"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="80dp"
android:id="#+id/LinearRemove">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_clear_black_18dp"
android:layout_marginLeft="05dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="REMOVE"
android:id="#+id/textView47"
android:layout_gravity="center"
android:layout_marginLeft="05dp"
android:textSize="14sp"
android:layout_marginRight="15dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="08dp"
android:id="#+id/imageView14"
android:background="#drawable/line2"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView10"
android:layout_marginStart="20dp"
android:background="#drawable/ic_place_black_48dp"
android:layout_marginTop="05dp"
android:layout_gravity="center" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Text_to"
android:drawableEnd="#drawable/ic_chevron_right_black_24dp"
android:layout_marginEnd="10dp"
android:text="#string/Loc"
android:layout_gravity="center"
android:layout_marginTop="05dp"
android:textAppearance="#android:style/TextAppearance.Medium"
android:cursorVisible="false"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Street/Building/Place"
android:layout_marginStart="48dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView17"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="#+id/editText_to_details"
android:layout_marginEnd="10dp"
android:hint="#string/LocationDetails"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textViewHouseDetailsTo"
android:layout_marginStart="48dp"
android:hint="#string/HouseDetails" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/LinearLayoutAdditionalContactTo">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView18"
android:layout_marginStart="20dp"
android:background="#drawable/ic_person_black_48dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/contactDetailsTo"
android:layout_marginEnd="10dp"
android:text="#string/additionalContact"
android:textAppearance="?android:attr/textAppearanceMedium"
android:drawableEnd="#drawable/ic_expand_more_black_24dp"
android:layout_marginTop="08dp"
android:layout_marginStart="05dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginEnd="50dp"
android:layout_gravity="center"
android:visibility="gone"
android:id="#+id/LinearLayoutTo"
android:layout_marginTop="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editTex"
android:layout_weight="1"
android:hint="Name"
android:layout_gravity="center"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editTe"
android:layout_weight="1"
android:hint="Phone"
android:layout_gravity="center"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/or"
android:id="#+id/textViewInputIfSender"
android:layout_gravity="center"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="220dp"
android:layout_height="40dp"
android:background="#drawable/shape"
android:layout_gravity="center_horizontal">
<ImageButton
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageButton1"
android:background="#drawable/phone2"
android:layout_gravity="center"
android:layout_marginStart="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/addFromContacts"
android:id="#+id/textView35"
android:layout_gravity="center"
android:layout_marginStart="20dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textViewInputReceiver"
android:layout_marginLeft="48dp"
android:hint="#string/contact1"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView12"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="#+id/editText_from_details"
android:layout_marginEnd="10dp"
android:hint="Instruction"
android:layout_gravity="center"
android:layout_marginLeft="10dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="#drawable/shape"
android:layout_gravity="right"
android:layout_marginEnd="15dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:id="#+id/LinearNextDestination">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_add_black_18dp"
android:layout_marginLeft="05dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="NEXT DESTINATION"
android:id="#+id/textView47"
android:layout_gravity="center"
android:layout_marginLeft="05dp"
android:textSize="14sp"
android:layout_marginRight="15dp" />
</LinearLayout>
</LinearLayout>
You are having many layout as the child layout for the main layout. But the better way to achieve your goal is to add fragment.
Using the fragment you can easily change the layouts view. Look at these links. Adding fragment will solve your problem.
http://developer.android.com/training/basics/fragments/creating.html
http://examples.javacodegeeks.com/android/core/app/fragment/android-fragments-example/
http://www.vogella.com/tutorials/AndroidFragments/article.html
http://www.learn2crack.com/2014/05/android-working-with-fragments.html
Using the fragment you can divide the space in the layout and add multiple fragments inside that.

my layout not align properly is go out of layout

below is my layout which ontain 5 butons i want to show button with equal width and height also margin of internal layout on top and below willbe same but screen show out of layout see image http://imgur.com/TBwf0gI i want to show my 5 buttons with eqal space form top and botton for all size screens but my screen show out of layout check it
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/layoutbordercolor" >
<ImageView
android:id="#+id/btnback"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingLeft="3dp"
android:paddingTop="10dp"
android:src="#drawable/back" />
<ImageView
android:id="#+id/bitmap"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:src="#drawable/logostar" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="12dp"
android:text="San Diego Unified"
android:textColor="#603311"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="SCHOOL DISTRICT"
android:textColor="#603311"
android:textSize="10sp" />
</LinearLayout>
<ImageView
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingTop="10dp"
android:src="#drawable/options1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:background="#drawable/layout_border"
android:orientation="vertical"
android:paddingBottom="30dp" >
<ImageView
android:id="#+id/facebook"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="45dp"
android:src="#drawable/facebook" />
<ImageView
android:id="#+id/twitter"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/twitter" />
<ImageView
android:id="#+id/farmtoschool"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/farm_to_school" />
<ImageView
android:id="#+id/takeasurvey"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/take_a_survey" />
<ImageView
android:id="#+id/test_button_image2"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginBottom="40dp"
android:layout_marginTop="15dp"
android:src="#drawable/share_this_app" />
</LinearLayout>
</LinearLayout>
try This....
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E5E5E5"
android:weightSum="100"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="20"
android:background="#drawable/layoutbordercolor" >
<ImageView
android:id="#+id/btnback"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingLeft="3dp"
android:paddingTop="10dp"
android:src="#drawable/back" />
<ImageView
android:id="#+id/bitmap"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:src="#drawable/logostar" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="12dp"
android:text="San Diego Unified"
android:textColor="#603311"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="SCHOOL DISTRICT"
android:textColor="#603311"
android:textSize="10sp" />
</LinearLayout>
<ImageView
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingTop="10dp"
android:src="#drawable/options1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="80"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:background="#drawable/layout_border"
android:orientation="vertical"
android:paddingBottom="30dp" >
<ImageView
android:id="#+id/facebook"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="45dp"
android:src="#drawable/facebook" />
<ImageView
android:id="#+id/twitter"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/twitter" />
<ImageView
android:id="#+id/farmtoschool"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/farm_to_school" />
<ImageView
android:id="#+id/takeasurvey"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/take_a_survey" />
<ImageView
android:id="#+id/test_button_image2"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginBottom="40dp"
android:layout_marginTop="15dp"
android:src="#drawable/share_this_app" />
</LinearLayout>
I will show you an example and you try to implement this
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/rl1">
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="click"/>
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="34dp"
android:layout_toRightOf="#+id/btn1"
android:text=" some text here" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="40dp">
<Button
android:id="#+id/abc"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:fontFamily="Arial" />
<Button
android:id="#+id/abc2"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="#+id/abc"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:fontFamily="Arial" />
</RelativeLayout>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Button" />
</RelativeLayout>
Always try to reduce the no of layouts inside a single layout. So to use RelativeLayout which is more customizable than others for any requirements
Use padding like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="your_size"
android:background="#E5E5E5"
android:orientation="vertical" >
This should works.

Categories

Resources