Reputation: 497
Found similar question but could not find best answer.
How to solve Layout problem on keypad display and on landscape screen in android?
Below are the images with problem occurring.
Above is original layout
Below its after keyboard on screen
In the 2nd picture layout after keyboard,Half button is missing and sign in textview is missing
Please help how i have to solve this?
Here is the 3rd picture
Having problem on landscape orientation missing both button and textview and not getting any scroll.
Here is the code
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/background"
android:padding="20dp"
android:paddingEnd="0dp"
android:scrollbars="vertical|horizontal"
>
<ImageView
android:layout_height="wrap_content"
android:src="@drawable/logo"
/>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="15dp">
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:ems="10"
android:layout_weight="1"
android:hint="Full Name"
android:textSize="16sp"
android:background="@drawable/radius"
android:inputType="textPersonName"
android:paddingLeft="10dp" >
<requestFocus />
</EditText>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:ems="10"
android:layout_weight="1"
android:hint="Username"
android:textSize="16dp"
android:background="@drawable/radius"
android:paddingLeft="10dp"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:inputType="textPersonName" />
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="40dp"
android:ems="10"
android:textSize="16sp"
android:hint="Email"
android:background="@drawable/radius"
android:inputType="textEmailAddress"
android:paddingLeft="10dp"
/>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:ems="10"
android:layout_weight="1"
android:hint="Password"
android:textSize="16sp"
android:layout_marginTop="15dp"
android:background="@drawable/radius"
android:inputType="textPassword"
android:paddingLeft="10dp"/>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp" >
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="@drawable/button_bg"
android:text="Register"
android:layout_weight="1"
android:layout_margin="2dp"
android:textColor="#FFF"/>
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom|center" >
<TextView
android:id="@+id/signIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|bottom|center"
android:linksClickable="true"
android:textColor="#FFF"
android:text="Sign In to addressbook"
/>
</TableRow>
</TableLayout>
Please help I will be very thankful to you Hello @Sam can you answer this question Please
Upvotes: 1
Views: 736
Reputation: 134714
If you want it scrollable, wrap your whole layout in a ScrollView
. As @AbdulHannan mentions in his answer, you can define the preferred behavior (resize vs pan) in the AndroidManifest, or programmatically in onCreate() (but not in both -- it's redundant). If you just wrap it in a ScrollView, Android will automatically use adjustResize
to resize your window, assuming that your ScrollView will handle the size change appropriately and be scrollable for the user.
Side design suggestion: That background is incredibly gaudy; try to make the pattern much more subtle if a pattern is necessary.
Upvotes: 2
Reputation: 368
In your Manifest.xml
, Under you're <activity>
include this,
android:windowSoftInputMode="stateVisible|adjustResize|adjustPan
and in your onCreate()
, add this:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
if you want the keyboard to be hidden whenever the Activity
is created.
Upvotes: 0