fragment in android studio not showing dashboard on my phone - android-studio

I am creating a dashboard for a bill payments app using android studio, I am trying to run the project on my phone and the fragment where the dashboard is supposed to appear is showing a blank screen. Apparently, there is a bottom navigation tab on the fragment which I want the dashboard to appear on.
Gradle build finished successfully and the dashboard is appearing the way I want it in the design tab but its not showing anything on my phone. What might be the problem? Below is the xml file for the dashboard. I haven't started working on the .java code as of yet.
<?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:background="#color/colorPrimary"
android:padding="10dp">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<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="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription="#null"
android:padding="10dp"
android:src="#drawable/zetdc" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/zesa_topup"
android:textColor="#000"
android:textSize="18sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription="#null"
android:padding="10dp"
android:src="#drawable/econet" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/econet_airtime"
android:textColor="#000"
android:textSize="18sp" />
</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="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription="#null"
android:padding="10dp"
android:src="#drawable/netone" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/netone_airtime"
android:textColor="#000"
android:textSize="18sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="#null"
android:padding="10dp"
android:src="#drawable/telecel" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/telecel_airtime"
android:textColor="#000"
android:textSize="18sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</ScrollView>

Code is working for me
Check this

Related

Layouts not visible despite the views being set to VIEW.VISIBLE

I have a working map fragment with a working navigation drawer in it.The 2 linear layouts are not visible despite being set to visible in the xml.Kind give me some help.what would be hiding those layouts?Where can i place for them to work.
I have tried a few solutions on line but none seemed to do the trick for me.
<FrameLayout
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/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="0">
<Button
android:id="#+id/CanelRide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cancel Ride"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:id="#+id/customerInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/white"
android:orientation="horizontal"
android:padding="10dp"
android:visibility="visible">
<ImageView
android:id="#+id/customerProfileImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:padding="20sp"
android:src="#drawable/mainicon" />
<TextView
android:id="#+id/customerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_marginTop="2dp"
android:gravity="left"
android:paddingBottom="3dp"
android:paddingLeft="5dp"
android:paddingRight="3dp"
android:text="Both Names"
android:textColor="#color/black"
android:textSize="19dp" />
</LinearLayout>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/driver_nav_header"
app:menu="#menu/driver_menu">
</android.support.design.widget.NavigationView>
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.design.widget.AppBarLayout>
</android.support.v4.widget.DrawerLayout>
Try to use the below layout, I have changed frame layout as child & drawer layout as parent
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<FrameLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="0">
<Button
android:id="#+id/CanelRide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cancel Ride"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:id="#+id/customerInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/white"
android:orientation="horizontal"
android:padding="10dp"
android:visibility="visible">
<ImageView
android:id="#+id/customerProfileImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:padding="20sp"
android:src="#drawable/mainicon" />
<TextView
android:id="#+id/customerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_marginTop="2dp"
android:gravity="left"
android:paddingBottom="3dp"
android:paddingLeft="5dp"
android:paddingRight="3dp"
android:text="Both Names"
android:textColor="#color/black"
android:textSize="19dp" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/driver_nav_header"
app:menu="#menu/driver_menu"/>
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"/>
</FrameLayout>
</android.support.v4.widget.DrawerLayout>

marginRight not working in RelativeLayout

I have the following code but somehow the button I have on the right is stuck to the edge instead of having a margin of 41dp to the left of imageView. Is there anyway I can have have a working marginRight of 41dp (similar to the left button I have)
Have been stuck at this simple problem for a ridiculous amount of time, help is appreciated!
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginBottom="50dp">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:padding="5dp"
app:cardCornerRadius="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="500dp">
<ImageView
android:id="#+id/image"
android:layout_width="338dp"
android:layout_height="338dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginStart="12dp"
android:layout_marginTop="4dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
app:srcCompat="#drawable/formal" />
<ImageButton
android:id="#+id/dislike"
android:layout_width="75dp"
android:layout_height="72dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="41dp"
android:layout_marginBottom="26dp"
app:srcCompat="#drawable/ic_thumbs_down_white" />
<ImageButton
android:id="#+id/like"
android:layout_width="75dp"
android:layout_height="72dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="41dp"
android:layout_marginBottom="26dp"
app:srcCompat="#drawable/ic_thumbs_up_white" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/image"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:layout_marginBottom="94dp"
android:text="WEAR THIS" />
</RelativeLayout>
</android.support.v7.widget.CardView>
Try this
<?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">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:padding="5dp"
app:cardCornerRadius="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:orientation="vertical">
<ImageView
android:id="#+id/image"
android:layout_width="338dp"
android:layout_height="338dp"
android:src="#mipmap/ic_launcher"
android:layout_margin="10dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="WEAR THIS"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="41dp"
android:layout_marginBottom="26dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:src="#mipmap/ic_launcher"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="41dp"
android:layout_marginBottom="26dp"
android:src="#mipmap/ic_launcher"/>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
The result is

Android Portrait to Landcape Slider & ImageView not responsive

My Portrait View is looks Fine
My Landscape View alignment is collapsed
this is my code of activity_main.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/img_slideshow_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="#+id/img_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/indicator"
android:background="#color/PrimaryColor"
android:gravity="center"
android:ellipsize="end"
android:paddingBottom="2dp"
android:paddingLeft="5dp"
android:paddingRight="2dp"
android:paddingTop="2dp"
android:singleLine="true"
android:textColor="#ededed" />
</RelativeLayout>
<View android:id="#+id/div_a"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_below="#+id/img_slideshow_layout"
android:background="#color/view_divider_color" />
<View android:id="#+id/div_b"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_below="#+id/div_a"
android:background="#color/view_divider_color_2" />
<com.studiobluelime.utils.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/view_pager"
android:layout_marginBottom="4dp" />
</RelativeLayout>
<!--<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
style="#style/Base.Widget.AppCompat.ProgressBar"
android:id="#+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true" />
<android.support.v7.widget.RecyclerView
android:id="#+id/card_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>-->
<!-- <android.support.v7.widget.RecyclerView
android:id="#+id/card_recycler_view_new"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"/>-->
</LinearLayout>
</ScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="100dp"
app:srcCompat="#drawable/shop_online"
android:layout_marginLeft="140dp"
android:id="#+id/shop_online"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:layout_marginTop="200dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/nandme"
android:adjustViewBounds="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="320dp"
android:scaleType="fitXY"
android:id="#+id/nandme"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
app:srcCompat="#drawable/storelocation"
android:adjustViewBounds="true"
android:layout_marginLeft="258dp"
android:id="#+id/storelocation"
android:scaleType="fitXY"
android:layout_marginTop="250dp"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
app:srcCompat="#drawable/promotins"
android:adjustViewBounds="true"
android:layout_marginLeft="20dp"
android:id="#+id/promotins"
android:scaleType="fitXY"
android:layout_marginTop="240dp"/>
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="fill_parent"
android:layout_height="157dp" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:itemIconTint="#color/PrimaryDarkColor"
app:itemTextColor="#color/colorAccent"
app:itemBackground="#drawable/ripple"
app:menu="#menu/navigation_items" />
</android.support.v4.widget.DrawerLayout>
I wrote this code in four layouts: layout/activity_main.xml,layout-small/ activity_main.xml, layout-large/activity_main.xml, layout-xlarge/activity_main.xml but it did not change. I have attached a screen shot here. Please click the above name "My Portrait View is looks Fine My Landscape View alignment is collapsed"

adding admobs on my android app

Please assist with something,I am trying to add admobs on the app but it doesn't show on the app when I run it, but it appears on the android studio preview. How do I fix that?
This code is on the main activity layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/relatively"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d15400"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.90"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:id="#+id/linearLayout11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:id="#+id/score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="Score : 1"
android:textColor="#ffffff"
android:textSize="25.0sp"
android:textStyle="bold" />
<TextView
android:id="#+id/timers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="00:00:49"
android:textColor="#ffffff"
android:textSize="25.0sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.60"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.40" >
<TextView
android:id="#+id/txtQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="15*2*1-1"
android:textColor="#ffffff"
android:textSize="35.0sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:orientation="vertical"
android:weightSum="1" >
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="5dp"
android:background="#fff"
android:gravity="center"
android:text="30"
android:textColor="#000000"
android:textSize="25.0sp" />
<Button
android:id="#+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="5dp"
android:background="#fff"
android:gravity="center"
android:text="29"
android:textColor="#000000"
android:textSize="25.0sp" />
<Button
android:id="#+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="5dp"
android:background="#fff"
android:gravity="center"
android:text="32"
android:textColor="#000000"
android:textSize="25.0sp" />
<!-- view for AdMob Banner Ad -->
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
this code is on the questions activity class -
setContentView(R.layout.activity_main);
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.setRequestAgent("android_studio:ad_template").build();
adView.loadAd(adRequest);

Align Linear Layout to the bottom

I have a layout and I want the last LinearLayout to be aligned on the very bottom. I attempted to set the gravity and the android:layout_marginbottom=0dp and neither one seems to align it to the bottom.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/item_detail_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".ItemDetailActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="154dp" >
<ImageView
android:id="#+id/albumArt"
android:layout_width="140dp"
android:layout_height="138dp"
android:src="#drawable/stealyourface" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_horizontal|center"
android:orientation="vertical" >
<TextView
android:id="#+id/artistName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#E6E6E6" />
<TextView
android:id="#+id/showLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#E6E6E6" />
<TextView
android:id="#+id/showDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#E6E6E6" />
<TextView
android:id="#+id/runningSong"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#E6E6E6" />
</LinearLayout>
<TextView
android:id="#+id/currentlyPlaying"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#E6E6E6" />
</LinearLayout>
<ScrollView
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="214dp"
android:background="#000000" >
<LinearLayout
android:id="#+id/songList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<!-- Player Buttons -->
**<LinearLayout
android:id="#+id/LinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:layout_marginBottom="0dp">
<RelativeLayout
android:layout_width="320dp"
android:layout_height="wrap_content"
android:background="#layout/rounded_corner"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<!-- Previous Button -->
<!-- Backward Button -->
<!-- Play Button -->
<ImageButton
android:id="#+id/btnPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnNext"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/btnBackward"
android:background="#null"
android:src="#drawable/btn_play" />
<!-- Forward Button -->
<!-- Next Button -->
<ImageButton
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/btnPlay"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#null"
android:src="#drawable/btn_previous" />
<ImageButton
android:id="#+id/btnBackward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnPrevious"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/btnPrevious"
android:background="#null"
android:src="#drawable/btn_backward" />
<ImageButton
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignTop="#+id/btnForward"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_toRightOf="#+id/btnForward"
android:background="#null"
android:src="#drawable/btn_next" />
<ImageButton
android:id="#+id/btnForward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/btnPlay"
android:background="#null"
android:src="#drawable/btn_forward" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>**
You have to use android:layout_gravity to do that, not android:gravity.
http://developer.android.com/reference/android/widget/FrameLayout.html
layout_gravity specifies the gravity in respect to the parent, gravity controls the placement of the content in the view itself.
You should take a relative layout as inner layout of linear layout. Like this example. I hope its useful for you.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/mainact"
android:weightSum="6" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:clickable="true"
android:onClick="func"
android:src="#drawable/somnath" />
<ImageView
android:id="#+id/imageView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:clickable="true"
android:onClick="func"
android:src="#drawable/ghrishneshwar" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/mallikarjun" />
<ImageView
android:id="#+id/imageView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/kedarnath" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/mahakaleshwar" />
<ImageView
android:id="#+id/imageView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/trayambkeshwar" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/omkareshwar" />
<ImageView
android:id="#+id/imageView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/kashim" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="90dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/vaidyanath" />
<ImageView
android:id="#+id/imageView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="90dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/nageshwar" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="170dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/bhimashankar" />
<ImageView
android:id="#+id/imageView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="170dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/rameshwaram" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>

Resources