i have a textview and a Menu , the textview is currently showing at the bottom of the screen and when menu pressed ,currently the menu hide the textview ,but i want the textview automatically move upwords so that everybody can see
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:background="#drawable/android_bg"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#drawable/navigationbar">
<TextView android:layout_width="wrap_content" android:layout_centerInParent="true"
android:id="#+id/banner_text"
android:layout_height="wrap_content" android:background="#drawable/bannertext_angies_list">></TextView>
<Button
android:layout_width="55dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_height="35dp"
android:background="#drawable/sign_out_button_clicked_button"
android:id="#+id/signout"/>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<TextView
android:visibility="gone"
android:textColor="#000000"
android:text="Thank you, your report has been"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="260dp"
android:layout_height="fill_parent"
android:id="#+id/Thanks_to_submission1"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:visibility="gone"
android:paddingLeft="70dp"
android:textColor="#000000"
android:text="submitted successfuly!"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="260dp"
android:layout_height="fill_parent"
android:id="#+id/Thanks_to_submission2"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp">
<Button
android:layout_width="260dp"
android:layout_height="fill_parent"
android:background="#drawable/submitbutton"
android:id="#+id/submitreport_providertype_button"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<Button
android:layout_width="260dp"
android:layout_height="fill_parent"
android:background="#drawable/searchlist_button"
android:id="#+id/search_list_button"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<Button
android:layout_width="260dp"
android:layout_height="fill_parent"
android:background="#drawable/bigdeal_button"
android:id="#+id/big_deal_button"/>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="14sp"
android:textStyle="bold"
android:onClick="true"
android:textColor="#000000"
android:text="Or visit our website at" />
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:id="#+id/link"
android:gravity="center_vertical"
android:autoLink="web"
android:linksClickable="true"
android:layout_gravity="center"
android:textSize="14sp"
android:textStyle="bold"
android:onClick="true"
android:textColor="#000000"
android:text="#string/link" />
</LinearLayout>
<TextView
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:text="Or visit our website at" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
That's not really supported by Android, and it's by design. The idea is that you can use the full screen for your UI, and the menu takes up part of the space when you need to select it. You don't want to worry about text views and other things while the menu is up. This is better than the iPhone, where you permanently have to give up screen space for menu items. If something is really important, then move it away from the bottom of the screen.
If you're really bent on moving stuff around, you could intercept Activity.onPrepareOptionsMenu and move things around in your UI, although the function wasn't really meant for that purpose. Then matching call is onOptionsMenuClosed.
Related
When I launch my app, I go to one of my screens to test out my game. Though, when I go to tap on the buttons, they don't work and do not change images like I wanted them to. So after various amounts of googling and testing, I believe I came across the problem. I believe I just have my text layer on top of my button layer, causing it so the buttons cannot be clicked as they are not the top layer. My issue here is I need the text on top to change constantly. How do I make it so my text does not interfere with my buttons.
I apologize for the big amount of code. The buttons are in the third relative layout, and the text is all in the middle.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageView"
android:background="#drawable/backgroundupg" />
</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView5"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:background="#drawable/upgrades"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight=".5">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="4">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/selector_state2_xml"
android:id="#+id/upgbutton"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/selector_state3_xml"
android:id="#+id/upgbutton1"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/selector_state4_xml"
android:id="#+id/upgbutton2"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/selector_state5_xml"
android:id="#+id/upgbutton3"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="8">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/upgtext"
android:text="Accuracy"
style="#style/Base.TextAppearance.AppCompat.Large"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="center_vertical|right"
android:id="#+id/pricetext"
android:text="100"
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:id="#+id/upg1cost"
android:background="#drawable/cookie" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/bottomtext"
android:text="Eh, close enough."
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/upgtext2"
android:text="Base Cookies"
style="#style/Base.TextAppearance.AppCompat.Large"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="center_vertical|right"
android:id="#+id/pricetext2"
android:text="500"
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:id="#+id/upg1cost"
android:gravity="center_vertical"
android:layout_alignRight="#+id/upgtext2"
android:background="#drawable/cookie" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/bottomtext2"
android:text="Double the cookies? Sweet!"
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/upgtext3"
android:text="Stopping Time"
style="#style/Base.TextAppearance.AppCompat.Large"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="center_vertical|right"
android:id="#+id/pricetext3"
android:text="1000"
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:id="#+id/upg1cost"
android:gravity="center_vertical"
android:layout_alignRight="#+id/upgtext3"
android:background="#drawable/cookie" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/bottomtext3"
android:text="I save an extra second!"
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/upgtext4"
android:text="Secret"
style="#style/Base.TextAppearance.AppCompat.Large"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="center_vertical|right"
android:id="#+id/pricetext4"
android:text="250 000"
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.5"
android:id="#+id/upg1cost"
android:gravity="center_vertical"
android:layout_alignRight="#+id/upgtext4"
android:background="#drawable/cookie" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/bottomtext4"
android:text="End game?!?!"
style="#style/Base.TextAppearance.AppCompat.Medium"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
</FrameLayout>
I also included an image to help give a visual representation of my code.
As well as my selector state for those who would like to know exactly what I put in it
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/button" android:state_enabled="true"></item>
<item android:drawable="#drawable/buttonclick" android:state_pressed="true"></item>
<item android:drawable="#drawable/buttongray" android:state_enabled="false"></item>
</selector>
Button is used when the user has enough cash to purchase the upgrade.
Buttongray is used when the user does not have enough cash, I do not want the button to be pressable then. The Button color just turns gray.
Buttonclick is just a highlight of Button.
I have tried interchanging both states as I thought that was the initial problem. Neither can be pressed.
the problem is because you are having your TextView objects above your Button objects and they steal the click event which you intend for the Button. The easiest fix would be to set:
android:focusable="false"
for all the TextView objects that overlay Button objects.
But I would still say your coding style needs to be improved. Why not dynamically change text in code based on events that happen in run time. You can use the setText(CharSequence text) method for buttons to dynamically set the text they should display.
You can use Button's attribute android:text="TEXT_HERE" in xml to set initial text for your button and later on with on click you can set a different text by this
Button button = (Button)findViewById(R.id.upgbutton);
button.setText("New_TEXT");
you button code in XML will look like this
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text = "Accuracy"
android:background="#drawable/selector_state2_xml"
android:id="#+id/upgbutton"
android:layout_gravity="center_horizontal" />
Since each "button" is so complex, you should consider creating a custom view.
I have a view TextViews and a WebView which I want to scull as a unit, instead of the WebView scrolling when required because of the content length. This is probably something simple, but I don't seem to be able to get it to work, as at all times the WebView has a scrollbar.
This is my Layout file:
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageView"
android:src="#drawable/background_tablet"
android:scaleType="centerCrop"
android:contentDescription="#string/background_image" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/list_background_overlay">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#color/list_background_overlay"
android:baselineAligned="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/author"
android:id="#+id/article_view_author"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/title"
android:id="#+id/article_titleView" android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/site"
android:id="#+id/article_view_site"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/date_unknown"
android:id="#+id/article_view_date"
android:gravity="right"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:background="#color/list_background_overlay"
android:id="#+id/article_mediaLayout"
android:padding="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/duration_default"
android:id="#+id/article_duration"
android:gravity="left"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/play"
android:id="#+id/article_playBttn"
android:layout_alignTop="#+id/article_preview"
android:layout_centerInParent="true"/>
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:id="#+id/article_preview"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:paddingRight="20dp"
android:contentDescription="#string/preview_image" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="512dp"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:id="#+id/relativeLayout">
</RelativeLayout>
</RelativeLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="15dp"
android:id="#+id/article_filler">
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/list_background_overlay"
android:paddingTop="20dp"
android:paddingBottom="20dp">
<WebView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/article_contentView" android:layout_gravity="center_horizontal"
android:padding="10dp"
android:paddingTop="30dp"
android:paddingBottom="20dp"/>
</FrameLayout>
Webview has a internal scroller. Because of that it's not a good option to wrap it in another scrollview. I don't know how complex your HTML is or whether it's a choice in your case anyway, but maybe you should think about to show it in a pure textview as discussed here: How to display HTML in TextView?
I'm using a layout for a configuration panel comprising a LinearLayout (vertical) containing two sub-views: a main subview that's a ScrollView (it has lots of stuff in it - more than fits on the screen, so I'm using the ScrollView to deal with that) and a panel that appears when something in the configuration panel changes (with the usual things: a button to save and a button to revert). The problem is that I can't convince the ScrollView to shrink to allow the "save/revert" panel any space on the screen.
Here's an excerpt of the layout file: [EDIT: added contents of ScrollView]
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView">
<TextView
style="?android:listSeparatorTextViewStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/tweeterLK_options"
android:layout_marginTop="15sp"
android:id="#+id/textView5"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fgIntervalPrompt"
android:id="#+id/fgEnable"
android:checked="true"
android:paddingRight="5dp"/>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/fgInterval"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<CheckBox android:id="#+id/bgEnable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/bgIntervalPrompt"
android:checked="true"
/>
<Spinner android:id="#+id/bgInterval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="#string/bgIntervalPrompt"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/tlkConfig_cacheDepth_prompt"
android:id="#+id/textView"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"/>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/cacheDepth"
android:prompt="#string/tlkConfig_cacheDepth_prompt"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tlkConfig_preload_avatar"
android:id="#+id/preload_avatar"
android:checked="true"
android:layout_weight="1"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tlkConfig_preload_images"
android:id="#+id/preload_images"
android:checked="false"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="visible">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/account"
style="?android:listSeparatorTextViewStyle"
android:layout_marginTop="15sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/signed_in_as"
android:id="#+id/signed_in_as"
android:visibility="visible"/>
<Button android:id="#+id/sign_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sign_in"
android:visibility="gone"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sign_out"
android:id="#+id/sign_out_button"
android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/lk_options_header"
style="?android:listSeparatorTextViewStyle"
android:layout_marginTop="14sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lkServer_enableLK"
android:id="#+id/lkServer_enable"
android:checked="false"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/lkServer_selection">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lkServer_serverListLabel"
android:id="#+id/lkServerLabel"
android:layout_gravity="center_vertical"
android:layout_marginRight="3dp"/>
<Spinner android:id="#+id/lkServerSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="#string/lkServerSpinnerPrompt"
android:longClickable="true"/>
</LinearLayout>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lkServer_inUse"
android:id="#+id/lkServer_useRecommendation"
android:checked="false"/>
</LinearLayout>
</ScrollView>
<LinearLayout android:id="#+id/settings_changed"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:visibility="gone">
<Button android:id="#+id/save"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="#string/save_settings"
/>
<Button android:id="#+id/revert"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="#string/reset_settings"
/>
</LinearLayout>
</LinearLayout>
When I make the #id/save layout visible (using setVisibility(View.VISIBLE)) it doesn't cause that ScrollView to resize. Any thoughts on why that is and what I should do about it?
I have 2 options: a) fix the size of the scrollview so that it always leaves room for the panel, or b) get rid of the panel and just pop up a dialog when the back button is pressed. I like the second one better mostly because I already have that working.
There is no content within the scrollview.Please add contents
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView">
//Place your layouts and contents here for things to get scroll
</ScrollView>
Hi i got the following code that represents a row of my listview.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/taxi_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/puerta"
android:layout_gravity="center" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:id="#+id/item_id"
android:text="-1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
android:layout_weight="1"/>
<TextView
android:id="#+id/item_name"
android:text="PIDALO RADIO TAXI"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFF09"
android:textSize="20dip"
android:layout_weight="1"
android:singleLine="true"
android:gravity="bottom"/>
<TextView
android:id="#+id/item_phone"
android:text="(011)4-988-0680"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="14dip"
android:singleLine="true"
android:layout_weight="1"
android:gravity="top"/>
</LinearLayout>
<ImageView
android:id="#+id/taxi_fav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/no_star"
android:layout_gravity="center_vertical"
android:layout_marginRight="6dip"/>
</LinearLayout>
</LinearLayout>
My problem is that between the two textviews ( item_name, item_phone ) there is a space even when the gravity of one is set to bottom and the other to top. I want the text of the item_name right on top of the item_phone, and right now there is a small gap.
Use this Layout instead:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:id="#+id/imageView1" android:layout_width="wrap_content"
android:src="#drawable/puerta" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"></ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toRightOf="#+id/imageView1"
android:id="#+id/textView1" android:text="PILADO RADIO TAXI"
android:textColor="#FFFF09" android:textSize="20dip"
android:singleLine="true" android:layout_marginTop="5dip"
android:gravity="bottom"></TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/textView2"
android:layout_alignLeft="#+id/textView1" android:layout_alignRight="#+id/textView1"
android:text="(011)4-988-0680" android:textSize="14dip"
android:singleLine="true" android:gravity="top"
android:layout_marginTop="25dip"></TextView>
<ImageView android:id="#+id/imageView2" android:layout_width="wrap_content"
android:src="#drawable/no_star" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_marginRight="30dip"></ImageView>
</RelativeLayout>
Here's my issue I have a login and want to line up the EditText fields. See the mockup picture attached .
I have tried a few ways and cannot figure out how to make the fields lineup.
I really hate layouts in Android I spend more time just messing with things to line up right. Wish they would just scrap it and use something more intuitive, as its more like using tables in HTML. So in advance thanks for your help and cheers!
You could probably play around with RelativeLayout and get just what you want.
Here's an approximation with TableLayout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_marginTop="40dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:padding="10dip"
android:text="UserID:" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="USER ID" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:padding="10dip"
android:text="Password:" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="PASSWORD" />
</TableRow>
</TableLayout>
<LinearLayout
android:layout_marginTop="50dip"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:gravity="center">
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="LOGIN" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="REGISTER" />
</LinearLayout>
</LinearLayout>
See if this works for you. It doesnt center quite perfectly but it does align well across multiple screen sizes.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#FFFF0000">
<LinearLayout android:id="#+id/top_row"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical" android:layout_centerHorizontal="true" android:layout_width="wrap_content" android:layout_marginTop="25dip">
<LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="fill_parent">
<TextView android:layout_height="wrap_content" android:text="User Id" android:gravity="right" android:layout_marginRight="10dip" android:layout_width="fill_parent" android:layout_weight="2" android:textColor="#FF000000"></TextView>
<EditText android:layout_height="wrap_content" android:layout_width="fill_parent" android:ems="10" android:layout_weight="1"></EditText>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="fill_parent">
<TextView android:layout_height="wrap_content" android:text="Password" android:gravity="right" android:layout_marginRight="10dip" android:layout_width="fill_parent" android:layout_weight="2" android:textColor="#FF000000"></TextView>
<EditText android:layout_height="wrap_content" android:layout_width="fill_parent" android:ems="10" android:layout_weight="1"></EditText>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_width="wrap_content" android:layout_below="#+id/top_row" android:layout_centerHorizontal="true" android:layout_marginTop="20dip">
<Button android:layout_width="wrap_content" android:text="LOGIN" android:layout_height="wrap_content" android:layout_marginRight="10dip"></Button>
<Button android:text="REGISTER" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="10dip"></Button>
</LinearLayout>
</RelativeLayout>
Here's what it looks like in my IDE...
You can do this quick and dirty using TableLayout, just add a TableRow with a TextView and a EditText for the userid and repeat the same for the password.
See http://developer.android.com/resources/tutorials/views/hello-tablelayout.html