When i write something on the edit text in my app ,the soft keyboard comes in along with a bottom relative layout..I want to fix the bottom relative layout position fixed.Any help will be greatly appreciated..
I'm guessing Padma Kumar meant android:windowSoftInputMode="adjustNothing" on your manifest activity tag.
add this in your activity tag in manifest.xml file
android:softinputmode="adjustNothing"
Make a fake layout with any height value, then reference it:
<RelativeLayout
android:id="#+id/rl_fake"
android:layout_width="fill_parent"
android:layout_height="320dp" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/rl_main_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
...
</RelativeLayout>
...
<RelativeLayout
android:id="#+id/rl_problem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/rl_fake" >
...
</RelativeLayout>
In Relative layout paste the following code
<LinearLayout
android:id="#+id/ll_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginTop="#dimen/_16dp">
<Button
android:id="#+id/btn_continue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="#string/conti"
android:padding="#dimen/_8dp"
android:textColor="#color/white"
android:textSize="#dimen/_16sp" />
</LinearLayout>
Related
I am struggling to figure out why my relativelayout screen is not filling the entire screen. I have tried a number of things, but the horizontal space of the screen never appears filled. What am i doing wrong?
<?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:id="#+id/splashscreen"
android:background="#color/splashScreenBackgroundColor"
>
<ImageView
android:id="#+id/imgLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="12sp"
android:textColor="#454545"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:text="MyAppName"
/>
</RelativeLayout>
The old name is deprecated, change the values to this..
android:layout_width="match_parent"
android:layout_height="match_parent"
Adding singletop will replace the last instance of your activity so if that solved your problem maybe you are instantiating your activity more than once somewhere, and that is why didnt worked before.
I figured out a solution. I added
"
android:launchMode="singleTop"
"
to the relativelayout and it solved the problem!
I have a relative layout which contains only the edit text view. But when content of edittext increases, my title bar gets shifted upwards. Most of the solutions I went through addresses the issue of shifting title bar when keyboard pops out. But I didn't found anything in case its content increases. I also used android:isScrollContainer="false" as suggested in this post How to avoid soft keyboard pushing up my layout?, but still the same issue. Is there a way to prevent it? Here is my xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="false"
android:background="#drawable/background" >
<EditText
android:id="#+id/hidden_edit_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine"
android:singleLine="false"
android:paddingLeft="10sp"
android:paddingTop="5sp"
android:paddingRight="5sp"
android:scrollbars="vertical"
android:background="#android:color/transparent"
android:textSize="26sp" >
</EditText>
</RelativeLayout>
I managed to solve this issue by putting edittext in scrollview and replacing adjustPan with adjustSize in the manifest. This is the final working layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rl_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background">
<EditText
android:id="#+id/hidden_edit_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine"
android:paddingLeft="10sp"
android:paddingRight="5sp"
android:paddingTop="5sp"
android:singleLine="false"
android:textSize="25sp" >
</EditText>
</ScrollView>
try to run your code after removing :
android:background="#android:color/transparent"
make your relative layout height and width to wrap_content.......... probably works. since when text increases your complete layout shifts. Try it and please rpy
Usually this can be solved by adding the android:windowSoftInputMode="adjustPan" property to your activity in the AndroidManifest file.
I have a following xml for my activity.
<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"
tools:context=".Activity1" >
<RelativeLayout
android:id="#+id/titleStoryRelativeLayout"
android:layout_weight="#string/titleWeight"
android:layout_width="fill_parent"
android:layout_height="0dip">
<TextView
android:id="#+id/titleStory"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/contentTextViewLayout"
android:layout_weight="#string/contentTextViewWeight"
android:layout_width="fill_parent"
android:layout_height="0dip">
<TextView
android:id="#+id/textViewStory1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/footerStoryRelativeLayout"
android:layout_weight="#string/footerWeight"
android:layout_width="fill_parent"
android:layout_height="0dip>
<Button
android:id="#+id/buttonPrevious"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:onClick="loadPrevious"
android:text="#string/stringButtonPrevious"/>
<Button
android:id="#+id/buttonNext"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:onClick="loadNext"
android:text="#string/stringButtonNext"/>
Here I am loading my Textview (#+id/textViewStory1) dynamically from my code with some text. The problem is that during loading, few lines go beyond the screen. I am planning to enable scrolling so as user can scroll down to view those missing lines. But the scrolling should only be limited till the last line and not beyond. Any suggestion on how can I set that?
Set these settings for your textview:
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
You can then set it to be scrollable in java:
TextView.setMovementMethod(new ScrollingMovementMethod());
Try to use ScrollView (official documentation)
You can limit the Height of TextView to match the number of lines you want to see, after that put your TextView in a ScrollView
I had done a simple example to demonstrate this...
<ScrollView android:layout_height="30dp"
android:layout_width="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:textSize="16sp"
android:id="#+id/tv1"
/>
</ScrollView>
Observe how I fixed ScrollView's height and matched TextView's height to it.
I had answered this exact question before here , please check for existing answers on SO before asking them again.
I've got problem with setting visibility to relative layout. I have part of big layout in relativelayout and below that next TextView. But in my code, when myRelativeLayout.setVisibility(View.GONE);
is called, TextView which is below that did not appear. I tried several ways to rearange layout, but i need that textview under it. Thanks
My XML:
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<ScrollView
android:id="#+id/scrollView_liab_ra_flipper_04"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/linearLayout_liab_ra_flipper_04"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/someTextView"
android:text="Something" />
<!-- This relative layout should be removable -->
<RelativeLayout
android:id="#+id/vg_liab_ra_04_flipper_car_container_visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/someTextView" >
<TextView
android:id="#+id/tv_1"
style="#style/WhiteFormText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="2dp"
android:text="#string/licence_plate_counter" >
</TextView>
<EditText
android:id="#+id/et_1"
style="#style/WhiteFormField"
android:layout_below="#+id/tv_1"
android:hint="#string/licence_plate_hint" >
</EditText>
</RelativeLayout>
<!-- This textview is not visible if relative layout is gone -->
<TextView
android:id="#+id/tv_liab_ra_04_flipper_mandat"
style="#style/WhiteFormTextHint"
android:layout_below="#+id/vg_liab_ra_04_flipper_car_container_visible"
android:layout_marginBottom="15dp"
android:text="#string/mandatory_field" >
</TextView>
</RelativeLayout>
</ScrollView>
</merge>
Java Code:
private void hideCar() {
if (!accident.getParticipant(0)) {
rlCarContainer.setVisibility(View.GONE);
} else {
rlCarContainer.setVisibility(View.VISIBLE);
}
}
The easiest way to do what you want is to use LinearLayout instead of your root RelativeLayout.. the child views will get realigned after you hide the RelativeLayout just the way you want.. if you don't want that, you can use android:layout_alignWithParentIfMissing on the TextView see here the documentation. That won't work exactly how you want but it might help you to solve the problem :).
I am trying to implement the following:
Please check the image here:
The problem is whenever the user taps the compose mail edittext field, the send/save/discard buttons are hidden by the softkeyboard.
Any ideas on how to make those buttons always visible?
Thanks.
[EDIT]
Finally got it solved!Had to use Linearlayout instead of RelativeLayout and assigning proper layout_weight parameter did the trick. Thanks a lot Femi for pointing out that the buttons need to be outside of the ScrollView.
Here is the final working layout xml in case anyone finds it helpful:
<?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"><ScrollView android:layout_alignParentTop="true"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/InnerRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<EditText
android:id="#+id/editTextCompose"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:gravity="top"
android:singleLine="false" android:lines="5"
android:inputType="text"
android:layout_below="#+id/editTextSubject"
>
</EditText>
</RelativeLayout>
</ScrollView><TableLayout android:id="#+id/recipeButtons"
android:background="#B0B0B0" android:padding="3dip"
android:stretchColumns="0,1" android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow android:gravity="center">
<Button android:id="#+id/editOtherAdditionButton"
android:text="Save" />
<Button android:id="#+id/removeOtherAdditionButton"
android:text="Delete" />
</TableRow>
</TableLayout></LinearLayout>
As documented in #mayra's answer to Android soft keyboard covers edittext field you should see http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft for the details to control.
Modifying the Activity's entry in the AndroidManifest to adjustResize should I think do it.
There is another question about this here, but it looks like the best approach is using the windowSoftInputMode