android: layout background turns black after hiding another layout - android

i have activity that display some info about school, and subscribe button
when the subscribe button is pressed, it shows another layout with edittext and button to enter subscription code
no the problem, if i pressed cancel the i got black background in the middle
this is the activity layout code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:id="#+id/linearLayout"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:background="#333"
android:layout_marginBottom="10dp"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="#+id/followOrgImage"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="5"
android:paddingLeft="7dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Untitled!"
android:id="#+id/titleTxt"
android:textStyle="bold"
android:textColor="#fff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="#+id/followTextDate"
android:textColor="#8B8B8B" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="#+id/followTextDesc"
android:textColor="#C4C4C4" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/followTextCountry"
android:textColor="#fafafa" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="250dp"
android:layout_height="45dp"
>
<Button
android:layout_width="125dp"
android:layout_height="fill_parent"
android:text="#string/follow"
android:id="#+id/follow_btn"
android:clickable="false"
android:layout_marginTop="5dp"
android:textColor="#ddd" />
<Button
android:layout_width="125dp"
android:layout_height="fill_parent"
android:text="#string/subscribe"
android:id="#+id/subscribe_btn"
android:clickable="false"
android:layout_marginTop="5dp"
android:textColor="#ddd" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:visibility="gone"
android:id="#+id/subscribe_layout"
>
<EditText
android:layout_width="186dp"
android:layout_height="wrap_content"
android:id="#+id/subscribe_edit_txt"
android:layout_marginTop="3dp"
android:textColor="#fafafa"
android:singleLine="true"
android:textCursorDrawable="#drawable/cursor_color"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:hint="#string/profiles_code_hint" />
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="#string/addBtn"
android:id="#+id/subscribe_add_btn"
android:clickable="false"
android:layout_marginTop="5dp"
android:textColor="#ddd" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:paddingLeft="15dp"
android:paddingTop="5dp"
android:paddingRight="15dp"
android:paddingBottom="5dp"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:id="#+id/linearLayout2"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/organization_type"
android:id="#+id/textView"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#B1B1B1"
android:layout_marginTop="4dp"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:id="#+id/linearLayout3"
android:paddingLeft="20dp"
android:paddingTop="5dp"
android:paddingRight="20dp"
android:paddingBottom="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:textColor="#444"
android:textSize="13sp"
android:id="#+id/typeTxt"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout3"
android:paddingLeft="15dp"
android:paddingTop="5dp"
android:paddingRight="15dp"
android:paddingBottom="5dp"
android:id="#+id/linearLayout4"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/address"
android:id="#+id/textView2"
android:textSize="15sp"
android:enabled="true"
android:textStyle="bold" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#B1B1B1"
android:layout_marginTop="4dp"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout4"
android:paddingLeft="20dp"
android:paddingTop="5dp"
android:paddingRight="20dp"
android:paddingBottom="15dp"
android:id="#+id/linearLayout5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:textColor="#444"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/addressTxt"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout5"
android:visibility="gone">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/hdnBtn"
android:visibility="gone"/>
</LinearLayout>
</RelativeLayout>
i tried to give some layouts this attributes
android:scrollingCache="false"
android:cacheColorHint="#00000000"
but it didn't solve it
any suggestions?

By seeing your requirement, There is no need of the extra tags that you have used like cacheColorHint.
Simply, show the first screen, then navigate the user to new screen on subscribe button click.
You need 2 different xml layouts for it.
Or 2nd approach could be, On click of Subscribe button, set visibility of old elements to gone and set visibility of new required elements to visible.

Related

Listview Row is not showing full element

I have listview in which I am setting six different things. And that is working awesome on normal size devices. But its gets chopped off from the last item of the single row that is Text view.
I do not understand why it is happening I have Used linear layouts. And why it is only getting chopped off in the large size devices like Samsung Tab 7" and 10"
although normal devices are showing it good.
Edit One : This is design of my Listview Row
Here is what my Layout of listview looks a like.
<?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:paddingLeft="10dp"
android:paddingRight="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:background="#drawable/box"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:weightSum="20">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:id="#+id/tv_row_customer_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/accepted_offer_text_size"
android:layout_marginTop="2dp"
android:text="Customer Name Goes Here"
android:textColor="#ffa123"
android:textSize="#dimen/accepted_offer_text_size" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/dialog_offer_name"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Offer Name Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/mail"
android:gravity="left|center"
android:paddingLeft="5dp"
android:text="Email Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_phone_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/call"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Phone Number Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/pin"
android:ellipsize="end"
android:gravity="left|center"
android:minLines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="Address Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_c_brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/cofin"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text=" Brand Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/clock"
android:paddingLeft="5dp"
android:text="Start-End Time Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="15dp"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text=" "
android:textColor="#AAAAAA" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_weight="15"
android:orientation="horizontal"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginBottom="5dp"
android:gravity="right"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="3">
<TextView
android:id="#+id/tv_row_total_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/no_of_persons"
android:gravity="center"
android:text="aa" />
<TextView
android:id="#+id/tv_row_total_acceptors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/acceptors"
android:gravity="center"
android:text="aa" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/calander_upper"
android:gravity="center">
<TextView
android:id="#+id/tv_row_month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:gravity="center"
android:hint="aa"
android:paddingTop="2dp"
android:textSize="#dimen/dialog_accept_offer_tvcontent_size" />
</LinearLayout>
<TextView
android:id="#+id/tv_row_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_row_month"
android:layout_alignStart="#+id/tv_row_month"
android:layout_below="#+id/tv_row_month"
android:layout_gravity="center"
android:background="#drawable/calander_lower"
android:gravity="center"
android:padding="0dp"
android:text="aa"
android:textSize="#dimen/dialog_accept_offer_tvcontent_size" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:focusable="false" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I added the Last textview empty so that it can be gets chopped off. but has no effect. I have debug my code and saw that in adapter the last textview is truly initialized and then the last textview gets the data. but its still not visible or chopped off.
Please help me just this minor problem is keeping me away to complete the app.
try to add "scrollView" so if your layout is not fit on any device it will scroll otherwise use weight in your layout so it will adjust according to each screen size. if you not understand you can ask question in comments, I will explain about that.
<?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:paddingLeft="10dp"
android:paddingRight="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:weightSum="20">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:id="#+id/tv_row_customer_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="Customer Name Goes Here"
android:textColor="#ffa123" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Offer Name Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center"
android:paddingLeft="5dp"
android:text="Email Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_phone_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Phone Number Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="left|center"
android:minLines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="Address Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_c_brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text=" Brand Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="Start-End Time Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="15dp"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text=" "
android:textColor="#AAAAAA" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_weight="15"
android:orientation="horizontal"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginBottom="5dp"
android:gravity="right"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="3">
<TextView
android:id="#+id/tv_row_total_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="aa" />
<TextView
android:id="#+id/tv_row_total_acceptors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="aa" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/tv_row_month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:gravity="center"
android:hint="aa"
android:paddingTop="2dp" />
</LinearLayout>
<TextView
android:id="#+id/tv_row_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_row_month"
android:layout_alignStart="#+id/tv_row_month"
android:layout_below="#+id/tv_row_month"
android:layout_gravity="center"
android:gravity="center"
android:padding="0dp"
android:text="aa" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:focusable="false" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I changed something

Android align close button to top right corner of the dialog box?

i am working on a custom dialog box and i want to place my close button to the top right corner of the dialog so that the close image would be partially in the dialog box and partially outside....
(https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSSfhWv1zPYhmCFVsO70qLY-CqGIKplU3TAVL6zdHaxvLZMsqYnwg)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/someborder"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="top|left"
android:orientation="vertical"
android:layout_weight="0.65">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="0.82" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:paddingBottom="10dp"
android:paddingLeft="8dp"
android:paddingRight="5dp"
android:paddingTop="10dp">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.30"
android:gravity="center"
android:shadowColor="#color/color"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1"
android:paddingLeft="1.2dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:gravity="center|center_vertical"
android:shadowColor="#color/color"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:gravity="center_vertical|center"
android:shadowColor="#color/color"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:gravity="center_vertical|center"
android:shadowColor="#color/color"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1" />
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/horizontal_line" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:orientation="vertical"
android:gravity="top|left"
android:layout_weight=".15">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:paddingLeft="12dp"
android:paddingBottom="5dp">
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="10dp"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:paddingTop="1.75dp"
android:src="#drawable/vertical_line" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="top|right"
android:layout_weight=".38">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".60"
android:orientation="horizontal"
android:gravity="top|right">
<ImageView
android:id="#+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
// Close button
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"/>
// Close Button
</LinearLayout>
<LinearLayout
android:id="#+id/linear_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".40"
android:orientation="vertical"
android:paddingBottom="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".40"
android:layout_gravity="center"
android:orientation="vertical" >
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="0.33"
android:textAlignment="center"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="0.33"
android:textAlignment="center"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="0.33"
android:textAlignment="center"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Like this image and its red close button.
Thanx everybody in advance..
Here is a way to do it. Place your content layout/view in the same FrameLayout as the close button.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- The following View represent the content. Note the margin -->
<View
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#44aa00"
android:layout_margin="18dp"
/>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="top|right"
android:src="#android:drawable/ic_menu_close_clear_cancel"
android:background="#ff0000"
/>
</FrameLayout>
Notes:
Content must be listed before the close button. Button drawn on top of content.
The button is placed in the top right corner by setting the 3 layout parameters:
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="top|right"
Set a margin on the content to get the "partially outside" effect.
I have one solution for that,
<FrameLayout 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" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/img_popup_one"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign In"
android:textColor="#color/clr_gray"
android:textSize="16dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/img_edittext_bg"
android:hint="Username"
android:padding="5dp"
android:singleLine="true"
android:textColorHint="#color/clr_gray" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/img_edittext_bg"
android:hint="Password"
android:inputType="textPassword"
android:padding="5dp"
android:singleLine="true"
android:textColorHint="#color/clr_gray" />
</LinearLayout>
</FrameLayout>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="right|top"
android:contentDescription="#string/contentDescription"
android:src="#drawable/img_popup_close" />
</FrameLayout>
</FrameLayout>

Set a LinearLayout to scroll

I have been reading many posts here in stackoverflow about making a linear layout scroll and have applied all the specific advices to make it work but it still does not show on the left hand side. I am new to android and not sure what i am doing wrong.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView1">
<LinearLayout
android:id="#+id/expense"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="start"
android:orientation="vertical"
tools:context=".Expense" >
<LinearLayout
android:id="#+id/tedsts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/testffg"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".30"
android:text="Matter"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/tedssss"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".65"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<TextView
android:id="#+id/tetxttx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/gray_dark"
android:visibility="invisible" />
<EditText
android:id="#+id/teetttsss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all"
android:ems="10"
android:gravity="top"
android:hint="dgdfgfgf"
android:inputType="textMultiLine" />
<LinearLayout
android:id="#+id/tesssstt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all_clickable_selector"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/yttrree"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".20"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/rrrefffe"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".75"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<RadioButton
android:id="#+id/dfgrrrrr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Cost"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gergrerrr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded_all_clickable"
android:ems="10"
android:hint=""
android:inputType="numberDecimal"
android:singleLine="true" >
</EditText>
<RadioButton
android:id="#+id/rerreee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gggrrrrre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/roundede"
android:ems="10"
android:hint="grrrergg."
android:inputType="numberDecimal"
android:singleLine="true"
android:visibility="gone" >
</EditText>
<EditText
android:id="#+id/65gfhhggf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded"
android:ems="10"
android:hint=""
android:inputType="numberDecimal" >
</EditText>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/gfhgfhtrhrth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="15dp"
android:visibility="gone" />
<TextView
android:id="#+id/ghjjhhhgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/expense_TV_total"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="#+id/hgjhhghjhg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/save_selector" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
use this :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView ...>
<LinearLayout ...>
...
...
</LinearLayout>
</ScrollView>
and set hieght to
android:layout_height="wrap_content"
as Karakuri said
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
//Your Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100">
// First Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing First Sub layout
// Second Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing Second Sub layout
similarly for 3rd,4rth,5th sub layouts and so on........
</LinearLayout> // Finishing Main Layout
</ScrollView> // Finishing ScrollView
Make the child of the ScrollView have android:layout_height="wrap_content" (currently yours has match_parent)
add
android:layout_width="match_parent"
android:layout_height="match_parent"
to your root ScrollView
I hope this code may be help you.
android:layout_width="match_parent"
android:layout_height="match_parent">

ListView in android should come in whole screen and other elements in the bottom

There is a list view and other text views in my screen.
I want to show the list in whole the screen and other elements in the bottom of the list.
Below is the code I used.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/header1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradients"
android:orientation="vertical"
android:paddingBottom="8dip"
android:paddingTop="8dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:gravity="center"
android:text="#string/shopping_cart"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:background="#color/white"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="#+id/purchase_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="2dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/requisitioner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/purchase_order"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="#string/image"
android:src="#drawable/shopping_cart" />
</RelativeLayout>
<TextView
android:id="#+id/products_and_services"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/products_and_services"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/lr1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.12" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/pagingPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lr1"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<TextView
android:id="#+id/note_to_approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="#string/note_to_approver"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/note"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:background="#color/white"
android:maxLines="10"
android:padding="5dp"
android:text="hijnjn"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<Button
android:id="#+id/approvers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/options_menu"
android:drawableRight="#drawable/arrow_right"
android:gravity="left|center"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#layout/btn_background" >
<Button
android:id="#+id/release_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#drawable/btn_blue"
android:text="Approve(1)/Reject(0)"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
My requirement: Now the list is scrolling within the given area. I want to show in the whole screen and the scrolling should be only for the screen.
Please help me to do this.
You should not put a Vertically scrolling widget/view (ListView) in another vertically scrolling view (ScrollView). Though there are a few ways mentioned here and here which might help you achieve what you wish but that will increase the CPU load.

background layout moving when soft keyboard displayed - android

I've got an input popup that I'm displaying over my activities main view that has some edit boxes in it. When the popup is displayed the activities view stays dimmed in the background (like with an alert dialog).
The issue I'm having is that when the keyboard comes up the popup is ok, but activities view in the background is shifting up. That view should be paused and I wouldn't have thought it would be affected by the keyboard at all. Is there any way to stop this from happening?
I've tried adding android:windowSoftInputMode="adjustPan" to the activity and to the pop-up with no luck.
Here's my activity layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" android:background="#drawable/main_bg">
<include android:id="#+id/header" layout="#layout/common_header" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<RelativeLayout
android:id="#+id/contentLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
>
<include android:id="#+id/btnBar" layout="#layout/common_button_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
<LinearLayout
android:id="#+id/webLayout"
android:layout_above="#+id/btnBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/blk"
android:layout_margin="10dp">
<WebView
android:id="#+id/WebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:background="#drawable/white"
>
</WebView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
and here is my pop-up layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/light_grey" android:layout_width="wrap_content" android:minWidth="300dp">
<LinearLayout
android:id="#+id/main_inner_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/white"
android:layout_margin="3dp"
>
<TextView
android:id="#+id/enter_txt"
android:text="Enter Cup Code Below:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="#color/black"
android:layout_gravity="left"
android:typeface="sans"
android:textSize="16dp"
android:layout_margin="10dp"
>
</TextView>
<RelativeLayout
android:id="#+id/code_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/white"
>
<EditText
android:text="12345"
android:id="#+id/CodeInputOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentLeft="true"
></EditText>
<EditText
android:text="12345"
android:id="#+id/CodeInputTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_centerHorizontal="true"
></EditText>
<EditText
android:text="12345"
android:id="#+id/CodeInputThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_alignParentRight="true"
></EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/btn_layout_top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#color/white"
>
<Button
android:id="#+id/AccountBtn"
android:textStyle="bold"
android:text="My Account"
android:layout_marginRight="5dp"
android:layout_alignParentLeft="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
<Button
android:id="#+id/SubmitBtn"
android:textStyle="bold"
android:text="Submit"
android:layout_marginLeft="5dp"
android:layout_alignParentRight="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
</RelativeLayout>
<RelativeLayout
android:id="#+id/btn_layout_bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/white"
>
<Button
android:id="#+id/RewardsBtn"
android:textStyle="bold"
android:text="Rewards"
android:layout_marginRight="5dp"
android:layout_alignParentLeft="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
<Button
android:id="#+id/CancelBtn"
android:textStyle="bold"
android:text="Cancel"
android:layout_marginLeft="5dp"
android:layout_alignParentRight="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Thanks!
Try using
android:windowSoftInputMode="adjustPan|adjustResize"
for the activity.

Categories

Resources