Two side by side Textviews with progress bar above and imageView below - android

I am trying to create two side by side Textview's both with centered text and of equal width, also with a progress bar above (top of screen) and an ImageView which should take up the remaining space below the two Textview's.
Here is what I have so far, currently the Textview's seem to be hidden.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:padding="6dip">
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/box1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/box2" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/desc"
android:src="#drawable/ic_launcher"
android:layout_gravity="center_horizontal" />
</LinearLayout>

You can try as below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:padding="6dip" >
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/box1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/box2" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/desc"
android:src="#drawable/ic_launcher" />
</LinearLayout>

Just remove the line
android:layout_weight="1"
from
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
which is below progressbar

Try doing as given below
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="6dip">
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="box1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="box2" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/desc"
android:src="#drawable/ic_launcher" />
</LinearLayout>

Related

Align Buttons in Linear Layout to the Bottom of the Screen

I have the following layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_gravity="center"
android:layout_width="200dip"
android:layout_height="200dip"
/>
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_marginLeft="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tview_total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Total Files Processed:" />
<TextView
android:id="#+id/tview_success"
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="wrap_content"
android:text="Successfully Processed:" />
<TextView
android:id="#+id/tview_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Error Processing:" />
</LinearLayout>
<LinearLayout
android:id="#+id/llBottomContainer2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:gravity="bottom"
android:padding="5dp" >
<Button
android:id="#+id/proceed2"
style="#style/btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#drawable/btn_sel"
android:text="Proceed" />
</LinearLayout>
</LinearLayout>
I want to align the Button on the bottom of the screen.I tried setting
android:layout_gravity="bottom"
android:gravity="bottom"
Does not work.What i'm i doing wrong?
try this :
<LinearLayout
android:id="#+id/llBottomContainer2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="bottom"
android:gravity="bottom"
android:padding="5dp" >
try this layout :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="200dip"
android:layout_height="200dip"
android:layout_gravity="center" />
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:orientation="vertical" >
<TextView
android:id="#+id/tview_total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Total Files Processed:" />
<TextView
android:id="#+id/tview_success"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Successfully Processed:" />
<TextView
android:id="#+id/tview_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Error Processing:" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llBottomContainer2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="vertical"
android:padding="5dp" >
<Button
android:id="#+id/proceed2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Proceed" />
</LinearLayout>
</RelativeLayout>
where android:layout_alignParentBottom="true" is key parameter.
Happy coding..
android:gravity="bottom"
Then make the gravity of layout or your button to the bottom

Trying to create a webview with progress bar and bottom tab

Below is my Code. I am not able to display the include element which is the tab in the bottom part of the page properly.It gets hidden. Any suggestions would be welcome.
Take a look at the code and let me know.
<LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/header_yellow" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dip"
android:orientation="horizontal" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/logo" />
<LinearLayout
android:layout_width="68dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dip" >
<ImageView
android:id="#+id/webview_scan_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:onClick="onScanner"
android:src="#drawable/barcode_icon" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="450dp"
>
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<include layout="#layout/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Although your question/desirable output are not clear, try this
<LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#aaaaaa" >
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<ImageView
android:id="#+id/webview_scan_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/progressBar1"
android:onClick="onScanner"
android:src="#android:drawable/ic_menu_search" />
<ImageView
android:id="#+id/webview_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#android:drawable/ic_menu_info_details" />
</RelativeLayout>
<WebView
android:layout_below="#+id/webview_scan_button"
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<include layout="#layout/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
You can customize your tub as you want, for examle:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/tabsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg_tab_gradient"
android:gravity="center"
android:orientation="vertical"
tools:ignore="contentDescription" >
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBar" />
<ImageView
android:id="#+id/tab_icon"
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tab_text"
android:layout_marginBottom="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/tab_text_color"/>
</LinearLayout>
using this examle you can use this layout and create Tabs at bottom: https://stackoverflow.com/a/23150258/2765497
for support api<11 replace TabView to FragmentTabVeiw and add enother imports from Sherlock of Support library

Android VideoView Black bar appearing at bottom

I have a videoview to play a video and after that some other buttons in that layout.But the black bar of the video is appearing on bottom of layout.What i should do to make the blackbar on videoview's bottom.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/White" >
<RelativeLayout
android:id="#+id/first_intro"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="14dp"
android:background="#color/intro2_bg"
android:padding="#dimen/sidearea_padding" >
<Button
android:id="#+id/remove_page_from_introthird"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:background="#drawable/cross" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/footer_btns_layout_linear"
android:layout_centerInParent="true"
android:layout_marginBottom="20dp" >
<VideoView
android:id="#+id/videoView_introthree"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent" />
</LinearLayout>
<LinearLayout
android:id="#+id/footer_btns_layout_linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="1" >
<Button
android:id="#+id/prev_btn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
android:layout_weight="0.5"
android:background="#drawable/previous_selecter" />
<Button
android:id="#+id/nxt_btn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_weight="0.5"
android:background="#drawable/get_start_selecter" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Try this :
<LinearLayout 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:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:padding="5dip" >
<Button
android:id="#+id/mSDCardbutton"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/play_sdcard" />
<Button
android:id="#+id/mServerbutton"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/play_server" />
<Button
android:id="#+id/mRawbutton"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/play_raw" />
</LinearLayout>
<Button
android:id="#+id/mbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/button" />
<VideoView
android:id="#+id/VideoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
In this layout, buttons are at top.You can keep it at bottom.
Hope this helps.

android gridview stop selecting clicking effect when change layout

Below is my gridview layout which works fine and clicks. But when I change my layout it's not clicking any more. Tell me why I just change xml not code. Tell me what is wrong in my xml? Why gridView stopped clicking? is it because of layout weight?
I'm changing from this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/image2"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:padding="5dp"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/title2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="10dp"
android:textColor="#000" />
</LinearLayout>
To this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image2"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="#+id/title2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:textColor="#000000" />
<TextView
android:id="#+id/title3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical" >
<Button
android:id="#+id/ButtonSendFeedback"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/roundshapebtn"
android:text="Order Now"
android:textColor="#ffffff"
android:textSize="15pt" />
</LinearLayout>
You have some spaces in your layout maybe your click events did not trigger becasue of this. Just use below layout and check if your problem is solved:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#58FA58"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/title2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#DF013A" />
<TextView
android:id="#+id/title3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#2EFEF7" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/ButtonSendFeedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dummy"/>
</LinearLayout>

SlidingDrawer content stops at previous sibling view

I've got a view with a SlidingDrawer at the bottom. When I open it, it does not open entirely and stops at previous sibling view.
Anybody can help?
Thanks
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:id="#+id/top_bar"
android:layout_width="fill_parent" android:layout_height="44dp"
android:background="#drawable/top_bar">
<ImageView android:id="#+id/btn_popup"
android:layout_width="20dp" android:layout_height="20dp"
android:background="#456463" android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp" />
</RelativeLayout>
<LinearLayout android:id="#+id/featured"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="50dp" android:background="#drawable/bg_goodidea">
<TextView android:id="#+id/featured_title"
android:layout_width="280dp" android:layout_height="wrap_content" />
<TextView android:id="#+id/featured_txt"
android:layout_width="280dp" android:layout_height="wrap_content" />
</LinearLayout>
<ViewStub android:id="#+id/menu_container"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</ViewStub>
<SlidingDrawer android:id="#+id/banner"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:handle="#+id/handle" android:content="#+id/content">
<TextView android:id="#id/handle" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#drawable/bg_banner_title"
android:text="banner title" android:paddingLeft="50dp"
android:gravity="center_vertical" />
<ImageView android:id="#id/content"
android:layout_width="fill_parent" android:layout_height="100dp"
android:background="#286427" />
</SlidingDrawer>
</LinearLayout>
Layout inflated in the ViewStub:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/menu_cat_0" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="100dp"
android:layout_marginTop="10dp">
<LinearLayout android:id="#+id/cat_2" android:tag="2"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_2" />
<TextView android:text="#string/cat_communes"
style="#style/IconTitle" />
</LinearLayout>
<LinearLayout android:id="#+id/cat_4" android:tag="4"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_4" />
<TextView android:text="#string/cat_hebergements"
style="#style/IconTitle" />
</LinearLayout>
<LinearLayout android:id="#+id/cat_3" android:tag="3"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_3_vide" />
<TextView android:text="#string/cat_agenda" style="#style/IconTitle" />
</LinearLayout>
<LinearLayout android:id="#+id/cat_10" android:tag="10"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_10" />
<TextView android:text="#string/cat_meteo" style="#style/IconTitle" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Don't put it in a LinearLayout. Put it in a RelativeLayout, so it can float over top of earlier children.

Categories

Resources