i'm working on android application for registration operations
i'm using
compile SdkVersion 24
buildToolsVersion "24.0.1"
compile 'com.android.support:appcompat-v7:24.2.1'
compile
'com.android.support:design:24.2.1'
and the xml code for this layout is:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="56dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="72dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="24dp"
android:src="#drawable/logo" />
<!-- Full Name Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_full_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Full_Name"
android:inputType="textCapWords" />
</android.support.design.widget.TextInputLayout>
<!-- User Name Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/User_Name"
android:inputType="textCapWords" />
</android.support.design.widget.TextInputLayout>
<!--Gender-->
<RadioGroup
android:id="#+id/RG"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="#drawable/man"
android:text="#string/Male" />
<RadioButton
android:id="#+id/female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="#drawable/woman"
android:text="#string/FeMale" />
</RadioGroup>
<!--Birthday-->
<TextView
android:id="#+id/input_birthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/BirthDay"></TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1">
<EditText
android:id="#+id/spinner_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Day"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1">
<EditText
android:id="#+id/spinner_month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Month"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1">
<EditText
android:id="#+id/spinner_year"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Year"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txt_lable_p"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="#string/Add_Contact_Info"
android:textColor="#color/ColorPrimaryDark"
android:textSize="#dimen/textSize_medium3" />
<ImageView
android:id="#+id/infoContact"
android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_menu_info_details"/>
</LinearLayout>
<!-- WhatsApp Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_whatsApp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/WhatsApp"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
<!-- PhoneNumber Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_phoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/PhoneNumber"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
<!-- Facebook Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Facebook"
android:inputType="textWebEditText" />
</android.support.design.widget.TextInputLayout>
<!-- Twitter Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_twitter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Twitter"
android:inputType="textWebEditText" />
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Password"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<!-- Confirm Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/input_confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Confirm_Password"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<!-- Question Password Label -->
<TextView
android:id="#+id/QPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/QPassword" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/input_Q_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Q1"
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
<!--job-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioGroup
android:id="#+id/RGJob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/lookjob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LookJob" />
<ImageView
android:id="#+id/infoLookJob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_menu_info_details"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/havejob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/HaveJob" />
<ImageView
android:id="#+id/infoHaveJob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_menu_info_details"/>
</LinearLayout>
<RadioButton
android:id="#+id/None"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="#string/NoThing" />
</RadioGroup>
</LinearLayout>
<TextView
android:id="#+id/attchjob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/AttachAds"
android:visibility="gone" />
<android.support.design.widget.TextInputLayout
android:id="#+id/ads_layout"
android:layout_width="match_parent"
android:layout_height="170dp"
android:layout_margin="10dp"
android:background="#drawable/et"
android:visibility="gone">
<EditText
android:id="#+id/input_ads"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_margin="10dp"
android:gravity="top"
android:inputType="textCapSentences|textMultiLine" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/attach_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:text="#string/Image"
android:textAllCaps="false"
android:textColor="#ffffff"
android:theme="#style/MyButton"
android:visibility="gone" />
<TextView
android:id="#+id/url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:visibility="gone" />
<ImageView
android:id="#+id/urlimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:adjustViewBounds="true"
android:visibility="gone" />
<!-- Signup Button -->
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginTop="24dp"
android:padding="12dp"
android:text="#string/signUp" />
<TextView
android:id="#+id/link_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:gravity="center"
android:text="#string/AlreadyLogin"
android:textColor="#color/primary_dark"
android:textSize="16dip" />
</LinearLayout>
</ScrollView>
when i run it , it appeared like this
register layout
java code for this field:
if (answerPassword.isEmpty() || Password.length() < 2 ) {
Answer.setError(getResources().getString(R.string.ErrorAnswer));
}
the error icon appear in both side of textinputlayout , why ?
Try to rebuild the project with com.android.support:design:24.1.0. There is some issue with 24.2.1 library. using another version in my project i couldn't even get error message. So 24.2.1 is the issue. change it to 24.1.0 and rebuild.
Related
I have a screen with view that get affected when the soft keyboard appears, the entire white portion is in a ScrollView:
When I set the windowSoftInputMode to adjustPan in the manifest, the keyboard covers the save button, which can't be pressed until the keyboard is collapsed:
If I set it to adjustResize, the the views are all raised to overlap each other:
In neither case does the screen scroll. What I would like is for all of the views to remain in their original positions, but allow the user to scroll to the bottom behind the keyboard, until the bottom of the screen below the save button is adjacent to the top of the open keyboard. Is this possible?
Edit: .xml layout:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<FrameLayout
android:id="#+id/paypalActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#color/app_yellow_bold">
<TextView
android:id="#+id/paypalToastContainer"
android:tag="paypal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#color/onboarding_button_blue"
android:elevation="1dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="30dp"
android:paddingBottom="5dp"
android:visibility="gone"
android:text="#string/payout_pay_pal_saved"
android:textColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="gone">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/radikal_bold"
android:paddingTop="50dp"
android:paddingBottom="30dp"
android:text="#string/payout_pay_pal_connect_title"
android:textColor="#color/black"
android:textSize="30sp"/>
<com.weare8.android.ui.widgets.BackButton
android:id="#+id/pp_back"
android:layout_width="wrap_content"
android:layout_marginTop="20dp"
android:layout_height="match_parent"/>
</FrameLayout>
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintTop_toBottomOf="#+id/paypalActionBar">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/paypalActionBar" android:id="#+id/frameLayout4">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/paypal_logo"
android:layout_width="252dp"
android:layout_height="67dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:src="#drawable/paypal_logo"/>
<TextView
android:id="#+id/paypalDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypal_logo"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:fontFamily="#font/radikal"
android:lineSpacingMultiplier="1.2"
android:text="#string/payout_pay_pal_description"
android:textColor="#color/app_dark_gray"
android:textSize="16sp"/>
<TextView
android:id="#+id/paypalWarning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypalDescription"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:fontFamily="#font/radikal"
android:lineSpacingMultiplier="1.2"
android:textStyle="italic"
android:text="#string/payout_pay_pal_payout_warning"
android:textColor="#color/app_light_gray"
android:textSize="14sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
>
<EditText
android:id="#+id/text_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_edit_text"
android:hint="#string/payout_pay_pal_email_hint"
android:elevation="2dp"
android:imeOptions="actionDone"
android:inputType="textEmailAddress"
android:fontFamily="#font/radikal"
android:maxLines="1"
android:layout_marginBottom="15dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingStart="20dp"
android:textColor="#color/black"
android:textSize="16sp"
android:textColorHint="#8A8A8A"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/text_dont_have_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="3dp"
android:fontFamily="#font/radikal"
android:text="#string/payout_pay_pal_question"
android:textColor="#color/app_dark_gray"
android:textSize="14sp"/>
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/radikal"
android:textStyle="bold"
android:textColor="#color/button_blue"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<TextView
android:id="#+id/saveButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/bg_button_blue_rounded"
android:layout_margin="25dp"
android:fontFamily="#font/radikal_bold"
android:gravity="center"
android:padding="20dp"
android:text="#string/payout_pay_pal_save"
android:textSize="16sp"
android:textColor="#color/white"/>
</FrameLayout>
</ScrollView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
If you want to scroll and save button also show in scrolling when soft keypad open, then you should have to move scroll view from white area to top of the view.
I have made a demo for you. try this one. I hope It might be helpful.
<!--If you your scroll view top of the layout it will resolve your problem-->
<ScrollView
android:id="#+id/scroll_view"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
>
<!--Toolbar demo-->
<LinearLayout
android:id="#+id/ll_toolbar"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#color/teal_200"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<!-- <ScrollView-->
<!-- android:id="#+id/scroll_view"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="#+id/ll_toolbar"-->
<!-- >-->
<!--Your white area of scroll which you want to scroll-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/white_portain"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_toolbar"
>
<TextView
android:id="#+id/tv_paypal_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PayPal"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#color/black"
android:textSize="35dp"
/>
<TextView
android:id="#+id/tv_sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Connect your PayPal account to receive \n payments!"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#color/black"
android:textSize="18dp"
app:layout_constraintTop_toBottomOf="#+id/tv_paypal_title"
/>
<TextView
android:id="#+id/tv_sub_2_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please note:You must have a minimum balance of \n$1.00 to make a payout via PayPal."
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#color/gray_600"
android:textSize="15dp"
app:layout_constraintTop_toBottomOf="#+id/tv_sub_title"
/>
<EditText
android:id="#+id/edit_email"
android:layout_width="0dp"
android:layout_marginTop="10dp"
android:hint="Enter your email"
android:paddingStart="10dp"
android:textColorHint="#color/gray_600"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
app:layout_constraintTop_toBottomOf="#+id/tv_sub_2_title"
app:layout_constraintStart_toStartOf="#+id/tv_sub_title"
app:layout_constraintEnd_toEndOf="parent"
/>
<TextView
android:id="#+id/tv_create_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dont have a PayPal account?"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="#+id/edit_email"
android:textColor="#color/gray_600"
android:textSize="15dp"
app:layout_constraintTop_toBottomOf="#+id/edit_email"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:layout_marginTop="160dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_create_one" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--</ScrollView>-->
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I follow your layout and try to fix it. now it's working as you want. if you get any trouble with this layout then i will happy to help you futher
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
>
<LinearLayout
android:id="#+id/ll_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical">
<FrameLayout
android:id="#+id/paypalActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#color/teal_200">
<TextView
android:id="#+id/paypalToastContainer"
android:tag="paypal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#color/black"
android:elevation="1dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="30dp"
android:paddingBottom="5dp"
android:visibility="gone"
android:text="#string/payout_pay_pal_saved"
android:textColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="gone">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="50dp"
android:paddingBottom="30dp"
android:text="#string/payout_pay_pal_connect_title"
android:textColor="#color/black"
android:textSize="30sp"/>
<ImageView
android:id="#+id/pp_back"
android:background="#drawable/ic_launcher_background"
android:layout_width="wrap_content"
android:layout_marginTop="20dp"
android:layout_height="match_parent"/>
</FrameLayout>
</LinearLayout>
<!-- <ScrollView android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:fillViewport="true"-->
<!-- app:layout_constraintTop_toBottomOf="#+id/paypalActionBar">-->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_toolbar"
android:id="#+id/frameLayout4">
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:paddingLeft="20dp"-->
<!-- android:paddingRight="20dp">-->
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/paypal_logo"
android:layout_width="252dp"
android:layout_height="67dp"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="#color/gray_600"/>
<TextView
android:id="#+id/paypalDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypal_logo"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
app:layout_constraintTop_toBottomOf="#+id/paypal_logo"
app:layout_constraintStart_toStartOf="#+id/paypal_logo"
android:lineSpacingMultiplier="1.2"
android:text="#string/payout_pay_pal_description"
android:textColor="#color/gray_600"
android:textSize="16sp"/>
<TextView
android:id="#+id/paypalWarning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypalDescription"
app:layout_constraintTop_toBottomOf="#+id/paypalDescription"
app:layout_constraintStart_toStartOf="#+id/paypalDescription"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:lineSpacingMultiplier="1.2"
android:textStyle="italic"
android:text="#string/payout_pay_pal_payout_warning"
android:textColor="#color/gray_600"
android:textSize="14sp"/>
<LinearLayout
android:id="#+id/ll_edittext"
app:layout_constraintTop_toBottomOf="#+id/paypalWarning"
app:layout_constraintStart_toStartOf="#+id/paypalDescription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:orientation="vertical"
>
<EditText
android:id="#+id/text_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/payout_pay_pal_email_hint"
android:elevation="2dp"
android:imeOptions="actionDone"
android:inputType="textEmailAddress"
android:maxLines="1"
android:layout_marginBottom="15dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingStart="20dp"
android:textColor="#color/black"
android:textSize="16sp"
android:textColorHint="#8A8A8A"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/text_dont_have_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="3dp"
android:text="#string/payout_pay_pal_question"
android:textColor="#color/black"
android:textSize="14sp"/>
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="asd"
android:textColor="#color/purple_700"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
<!-- </RelativeLayout>-->
<View
android:id="#+id/spacing"
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_edittext"
/>
<TextView
android:id="#+id/saveButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="25dp"
android:background="#color/teal_200"
android:gravity="center"
android:padding="20dp"
android:text="#string/payout_pay_pal_save"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spacing"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- </ScrollView>-->
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Try this...its working fine for me. Please change color names in this layout xml and their hex code in your values>.color .xml and also the string values to get desired results.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
tools:ignore="UnknownIdInLayout">
<LinearLayout
android:id="#+id/idLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:padding="5dp"
app:layout_constraintTop_toBottomOf="#+id/idTopic"
tools:ignore="MissingConstraints">
<TextView
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_gravity="center"
android:gravity="center|top"
android:text="Your Text/nYourImage"
android:padding="10dp"
android:background="#00ffff"
android:textColor="#66ff33"
android:textSize="45sp"
/>
<EditText
android:id="#+id/idUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyz.#1234567890_"
android:inputType="textEmailAddress"
android:imeOptions="actionDone"
android:maxLength="40"
android:hint="email"
android:padding="10dp"
android:gravity="center"
android:layout_marginTop="15dp"
android:textSize="15sp"
android:background="#cccccc"
/>
<EditText
android:id="#+id/idPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:imeOptions="actionDone"
android:hint="password"
android:padding="10dp"
android:gravity="center"
android:layout_marginTop="15dp"
android:textSize="15sp"
android:autofillHints=""
android:background="#cccccc"/>
<Button
android:id="#+id/idLogin"
android:layout_width="wrap_content"
android:minWidth="100dp"
android:layout_height="40dp"
android:text="login"
android:textStyle="bold"
android:textAllCaps="true"
android:gravity="center"
android:textSize="15sp"
android:layout_marginTop="10dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="#ffff00"
android:textColor="#ffffff"
/>
<Button
android:id="#+id/idReset"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="forgot"
android:textAllCaps="true"
android:gravity="center"
android:textSize="15sp"
android:layout_marginTop="30dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="#ffff00"
android:textColor="#ffffff"
/>
<Button
android:id="#+id/idSignup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="sign up"
android:textAllCaps="true"
android:gravity="center"
android:textSize="15sp"
android:layout_marginTop="30dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="#ffff00"
android:textColor="#ffffff"
/>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
I'm creating an Activity which user can create a Question and where can create answers, so, from now I have this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/viewBinary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/constraintAnswerTypes"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_view_option_1_binary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<RadioButton
android:id="#+id/cb_answer1_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp" />
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_1_binary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:hintTextAppearance="#style/TextLabel">
<EditText
android:id="#+id/et_option1_binary"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="#string/respuesta_1"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/cb_answer2_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp" />
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_2_binary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:hintTextAppearance="#style/TextLabel">
<EditText
android:id="#+id/et_option2_binary"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="#string/respuesta_2"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
And the result is this one :
The problem that I'm having is if the answer that user types is too long he can not see it , so I'm thinking to do something like match_parent on the width so user has more space to write, but then I have this also :
And perhaps create 4 different lines for each answer is kinda ugly...
My initial question is, how do I create the first output to be match_parent like if there's only 2 answers, but then the thing is when I have the four answers, how do I print those EditText?
Edit
For the first option I want something like this, there 2 lines are the TextInputLayout with the EditTexts and the circle on the right is the RadioButton
Please check below code. It will solve your issue for both case, just need to handle visibility for alternate answers. If you face any issue then please let me know in comment section.
Use your own drawables and assets.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/viewBinary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linear_view_option_1_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_1_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 1"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer1_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_3_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:visibility="gone">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_3_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option3_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 3"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer3_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linear_view_option_2_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_2_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option2_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 2"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer2_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_4_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:visibility="gone">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_4_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option4_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 4"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer4_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
For Vertical layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/viewBinary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_view_option_1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_1_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 1"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer1_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_3_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_3_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option3_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 3"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer3_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_2_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_2_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option2_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 2"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer2_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_4_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_4_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option4_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 4"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer4_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
</LinearLayout>
Please approve answer if it will work for you. Thanks!
Try this
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerHorizontal="true" android:id="#+id/linear_view_option_1_binary">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_weight = 1
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:hintTextAppearance="#style/TextLabel"
android:id="#+id/txt_input_option_1_binary"
android:layout_marginBottom="8dp">
<EditText android:id="#+id/et_option1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:hint="#string/respuesta_1"/>
</android.support.design.widget.TextInputLayout>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:layout_marginBottom="8dp" android:id="#+id/cb_answer1_binary_option"/>
</LinearLayout>
Basically we are setting layoutweit to be equal 1 on the edit text (or textinput in your case) and the width to 0dp. This way Edittext will consume only the available space, not the whole width
<LinearLayout
android:id="#+id/linear_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:hintTextAppearance="#style/TextLabel">
<EditText
android:id="#+id/edt_option"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/rb_answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
I have layout for my activity and it shows up everything besides two edittexts, here it is.
<?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="wrap_content"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.hrle.androidapp.activity.ReadPostActivity"
android:id="#+id/arp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_rp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorAccent"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
/>
<ImageView
android:id="#+id/slika"
android:layout_width="220dp"
android:layout_height="141dp"
android:layout_below="#+id/naslov"
android:layout_marginEnd="5dp"
android:layout_toStartOf="#id/autor"
app:srcCompat="#mipmap/ic_launcher" />
<TextView
android:id="#+id/naslov"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:textAlignment="center"
android:textSize="40dp" />
<TextView
android:id="#+id/autor"
android:layout_width="190dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_below="#+id/naslov"
android:text="Autor: "
android:textSize="12sp" />
<TextView
android:id="#+id/datum"
android:layout_width="190dp"
android:layout_height="42dp"
android:layout_alignParentEnd="true"
android:layout_below="#+id/autor"
android:text="Datum: "
android:textSize="12sp" />
<TextView
android:id="#+id/lokacija"
android:layout_width="190dp"
android:layout_height="42dp"
android:layout_below="#+id/datum"
android:layout_alignParentEnd="true"
android:text="Lokacija: "
android:textSize="12sp" />
<TextView
android:id="#+id/likes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_below="#+id/opis"
android:drawableLeft="#drawable/ic_like"
/>
<TextView
android:id="#+id/dislikes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/likes"
android:layout_marginStart="30dp"
android:layout_below="#id/opis"
android:drawableStart="#drawable/ic_dislike" />
<TextView
android:id="#+id/opis"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_below="#+id/slika"
android:background="#drawable/border"
/>
<EditText
android:id="#+id/naslov_za_unos"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_above="#id/lv_comments"
android:layout_below="#id/likes"
android:hint="Unesite naslov"
android:inputType="text"/>
<EditText
android:id="#+id/opis_za_unos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/lv_comments"
android:layout_below="#id/naslov_za_unos"
android:hint="Unesite opis"
android:inputType="text"
/>
<Button
android:id="#+id/dugme_potvrde_kom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/dislikes"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp"
android:layout_marginEnd="100dp"
android:text="Objavi"
/>
<android.support.v7.widget.RecyclerView
android:id="#+id/lv_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/likes"
android:layout_marginTop="100dp"
/>
</RelativeLayout>
</ScrollView>
Here is the picture of design, edittexts should show up on position which I marked on picture. Can anyone figure out what makes it not show? And yes, I did everything in activity(findViewById etc.)
https://imgur.com/EltSZbi
Replace your code with these lines of code, I have used the LinearLayout for your view alignment, have a look in below solution
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/arp"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.hrle.androidapp.activity.ReadPostActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_rp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorAccent"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
/>
<ImageView
android:id="#+id/slika"
android:layout_width="220dp"
android:layout_height="141dp"
android:layout_below="#+id/naslov"
android:layout_marginEnd="5dp"
android:layout_toStartOf="#id/autor"
app:srcCompat="#mipmap/ic_launcher" />
<TextView
android:id="#+id/naslov"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:textAlignment="center"
android:textSize="40dp" />
<TextView
android:id="#+id/autor"
android:layout_width="190dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_below="#+id/naslov"
android:text="Autor: "
android:textSize="12sp" />
<TextView
android:id="#+id/datum"
android:layout_width="190dp"
android:layout_height="42dp"
android:layout_alignParentEnd="true"
android:layout_below="#+id/autor"
android:text="Datum: "
android:textSize="12sp" />
<TextView
android:id="#+id/lokacija"
android:layout_width="190dp"
android:layout_height="42dp"
android:layout_alignParentEnd="true"
android:layout_below="#+id/datum"
android:text="Lokacija: "
android:textSize="12sp" />
<TextView
android:id="#+id/likes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/opis"
android:layout_marginStart="100dp"
android:drawableLeft="#drawable/ic_like"
/>
<TextView
android:id="#+id/dislikes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/opis"
android:layout_marginStart="30dp"
android:layout_toEndOf="#id/likes"
android:drawableStart="#drawable/ic_dislike"
/>
<TextView
android:id="#+id/opis"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_below="#+id/slika"
android:background="#mipmap/ic_launcher" />
<LinearLayout
android:id="#+id/ll_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dislikes"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<EditText
android:id="#+id/naslov_za_unos"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#id/lv_comments"
android:layout_below="#id/likes"
android:hint="Unesite naslov"
android:inputType="text" />
<EditText
android:id="#+id/opis_za_unos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/lv_comments"
android:layout_below="#id/naslov_za_unos"
android:hint="Unesite opis"
android:inputType="text" />
</LinearLayout>
<Button
android:id="#+id/dugme_potvrde_kom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/dislikes"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_weight="1"
android:gravity="center"
android:text="Objavi"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/lv_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_input"
android:layout_marginTop="10dp" />
</RelativeLayout>
Try this:
<EditText
android:id="#+id/naslov_za_unos"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_above="#id/opis_za_unos"
android:layout_below="#id/likes"
android:layout_alignParentStart = true
android:hint="Unesite naslov"
android:inputType="text"
/>
<EditText
android:id="#+id/opis_za_unos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/lv_comments"
android:layout_below="#id/naslov_za_unos"
android:layout_alignParentStart = true
android:hint="Unesite opis"
android:inputType="text"
/>
The problem is that RecyclerView with height = "wrap_content" doesn't wrap all content, but it measure height to only 2 adapter items.
Best describe this screenshots : http://imgur.com/a/ErvXT
It worked fine for me since 23.2.0 update, but now for some unknown reason stopped work.
I have tried with compile com.android.support:recyclerview-v7:23.2.0 , 23.2.1, 24.0.0 and it doesn't work on any of this versions.
Code:
Gradle:
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "xxx"
minSdkVersion 16
targetSdkVersion 23
versionCode 93
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
dependencies {
...
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
...
}
Java:
final LinearLayoutManager layoutManagerFlavors = new LinearLayoutManager(getActivity());
recyclerViewFlavors.setLayoutManager(layoutManagerFlavors);
recyclerViewFlavors.addItemDecoration(new DividerItemDecoration(getActivity(), null));
//recyclerViewFlavors.setNestedScrollingEnabled(false);
FlavosAdapter flavorsAdapter = new FlavosAdapter(getActivity(), new ArrayList<Flavor>());
recyclerViewFlavors.setAdapter(flavorsAdapter);
XML:
<LinearLayout
android:id="#+id/linear_layout_fragment_liquids_views_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
<TextView
android:id="#+id/liquid_name"
style="#style/TextViewStyleTitle"
android:text="#string/liquid_name"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
android:visibility="gone" />
<TextView
android:id="#+id/liquid_description"
style="#style/TextViewStyleTitle"
android:text="#string/liquid_description"
android:visibility="gone" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_target_big" />
<TextView
style="#style/TextViewTitleBig"
android:text="#string/liquid_target" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="#style/TextViewStyleTitleTwo"
android:drawableLeft="#drawable/ic_target_liquid"
android:text="#string/liquid_amount" />
<TextView
style="#style/TextViewStyleTitleTwo"
android:drawableLeft="#drawable/ic_nicotine_strength"
android:text="#string/liquid_str" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_ml"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_ml"
style="#style/EditTextInteger"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="[ml]"
android:text="10" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_strength"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_strength"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="[mg/ml]"
android:text="6" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<TextView
style="#style/TextViewStyleTitle"
android:drawableLeft="#drawable/ic_vpg"
android:text="#string/liquid_subtitle_target_ratio"
android:textSize="16sp" />
<app.minimize.com.seek_bar_compat.SeekBarCompat
android:id="#+id/slider_target"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="20dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_vg"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_vg"
style="#style/EditTextInteger"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="VG [%]" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_pg"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_pg"
style="#style/EditTextInteger"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="PG [%]" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_margin="8dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="#drawable/ic_flavors_big" />
<TextView
style="#style/TextViewTitleBig"
android:text="#string/liquid_flavors_title" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_flavors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="vertical">
<ImageButton
android:layout_marginBottom="2dp"
android:id="#+id/image_button_add_flavor"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:background="#00000000"
android:src="#drawable/ic_add" />
<ImageButton
android:layout_marginTop="2dp"
android:id="#+id/image_button_add_flavor_from_database"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:background="#00000000"
android:src="#drawable/ic_add_flavor_from_database" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_name"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="5">
<AutoCompleteTextView
android:id="#+id/edit_text_flavor_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/hint_flavor_name"
android:inputType="text"
android:textSize="15sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_percentage"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="2">
<android.support.design.widget.TextInputEditText
android:id="#+id/edit_text_flavor_percentage"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="[%]" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_vpg"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="#+id/edit_text_flavor_vpg"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="PG[%]"
android:text="100" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_price"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="#+id/edit_text_flavor_price"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_price_for_10ml" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="8dp"
android:layout_weight="1"
android:background="#color/textColorSecondary" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:id="#+id/result_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_recipe_big" />
<TextView
android:id="#+id/text_view_recipe"
style="#style/TextViewTitleBig"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/liquid_recipe_title" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatButton
android:id="#+id/text_view_show_results"
style="?android:attr/buttonStyleSmall"
android:layout_width="110dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/showresults"
android:text="#string/liquid_button_show_results"
android:textColor="#color/textColorWhite" />
<ToggleButton
android:id="#+id/image_button_toggle_chart"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="#drawable/toggle_chart"
android:textOff=""
android:textOn="" />
<ImageButton
android:id="#+id/image_button_show_save"
style="?android:attr/borderlessButtonStyle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#drawable/ic_save_recipe" />
<ImageButton
android:id="#+id/image_button_show_share"
style="?android:attr/borderlessButtonStyle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#drawable/ic_share_liquid" />
<ImageButton
android:id="#+id/image_button_show_settings"
style="?android:attr/borderlessButtonStyle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#drawable/ic_settings" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/adView_blender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_blender" />
<RelativeLayout
android:id="#+id/results_titles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible">
<TextView
android:id="#+id/result_row_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/linearLayout2"
android:text="#string/results_name"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/result_row_percentage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="[%]"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/result_row_ml"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:gravity="right"
android:text="[ml]"
android:textSize="18sp"
android:textStyle="bold" />
<me.grantland.widget.AutofitTextView
android:id="#+id/result_row_drips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:gravity="right"
android:text="#string/result_drips_title"
android:textSize="16sp"
android:textStyle="bold"
autofit:minTextSize="10sp" />
<TextView
android:id="#+id/result_row_weight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:gravity="right"
android:text="[g]"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/result_row_cost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:gravity="right"
android:text="[$]"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_results"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<lecho.lib.hellocharts.view.PieChartView
android:id="#+id/chart"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
<LinearLayout
android:id="#+id/linear_layout_consume_batch"
android:visibility="gone"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/ask_if_consume_flavors_from_batch" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
style="#style/Base.Widget.AppCompat.Button.Borderless"
android:layout_weight="1"
android:text="#string/cancel"
android:id="#+id/button_cancel_consume"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
style="#style/Base.Widget.AppCompat.Button.Borderless"
android:layout_weight="1"
android:text="#string/consume"
android:id="#+id/button_apply_consume"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<Space android:layout_height="50dp"
android:layout_width="match_parent" />
</LinearLayout>
Item View
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="20dp">
<TextView
android:id="#+id/result_row_name"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/linearLayout"
android:layout_toStartOf="#+id/linearLayout"
android:maxLines="1"
android:singleLine="true"
android:text="Name"
android:textSize="18sp"
/>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="230dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="right">
<TextView
android:id="#+id/result_row_percentage"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:text="50.0"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_ml"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:text="100.0"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_drips"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:maxLength="6"
android:text="3"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_weight"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:maxLength="6"
android:text="3"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_cost"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:text="10.5"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
Must be very simple to solve but I'm not able to solve this.
I want to align the "top image and log_in_box", so the whole thing appear in exact center (Horizontal+Vertical center) of the screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Current Look
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true" >
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription=""
android:src="#drawable/ic_launcher" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="User ID"
android:inputType="text" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password"
android:inputType="textPassword" />
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:checked="true"
android:text="Remember Me" />
<Button
android:id="#+id/log_in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Log In" />