Android:placing layouts over each other - android

i am having an issue in over-lapping layouts,i am trying to implement an login form with in the entire page , and a button at the bottom , when the user press this button a registration form slides from bottom to up , my problems are:the first the registration form push the entire screen (i want it to overflow), the second: that i have 2 buttons with a shape background that appears on the top of registration form and the login inputs remains active
my xml code
<?xml version="1.0" encoding="utf-8"?>
<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/content_login_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg"
tools:context="com.example.a3wd.mytest10.LoginPage"
tools:showIn="#layout/activity_login_page">
<ImageView
android:id="#+id/login2Logo"
android:layout_width="50dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:contentDescription="#string/fixawy_logoPic"
android:src="#drawable/logo2" />
<LinearLayout
android:id="#+id/loginInputs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login2Logo"
android:layout_marginTop="30dp"
android:orientation="vertical">
<TextView
android:layout_width="140dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:text="#string/loginText"
android:textColor="#color/loginText"
android:textSize="24sp"
android:textStyle="bold" />
<EditText
android:id="#+id/userEmail"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/myspinner"
android:hint="#string/nameHint"
android:inputType="textEmailAddress"
android:padding="10dp" />
<EditText
android:id="#+id/userPassword"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="8dp"
android:background="#drawable/myspinner"
android:hint="#string/passwordHint"
android:inputType="textPassword"
android:padding="10dp"
android:textAlignment="textEnd" />
</LinearLayout>
<Button
android:id="#+id/loginBtn"
android:layout_width="96dp"
android:layout_height="56dp"
android:layout_below="#id/loginInputs"
android:layout_marginLeft="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/shape_round_corner"
android:text="#string/enterBtnTxt"
/>
<TextView
android:id="#+id/passwordText"
android:layout_width="150dp"
android:layout_height="30dp"
android:layout_alignBaseline="#id/loginBtn"
android:layout_alignParentRight="true"
android:layout_below="#id/loginInputs"
android:layout_marginRight="50dp"
android:text="#string/forgetPassword"
android:textColor="#color/loginText"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/facebookTxt"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_below="#id/loginBtn"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/facebookTxt"
android:textSize="18sp" />
<Button
android:id="#+id/facebookBtn"
android:layout_width="88dp"
android:layout_height="32dp"
android:layout_below="#id/facebookTxt"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#drawable/facebookbtn"
android:text="#string/facebook_btn"
android:textColor="#ffffff" />
<TextView
android:id="#+id/newUserTxt"
android:layout_width="140dp"
android:layout_height="20dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="#string/newUserTxt"
android:textSize="18sp"
android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_above="#+id/registrationBtn"
/>
<Button
android:id="#id/registrationBtn"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#drawable/register_btn_shape"
android:gravity="right"
android:onClick="registerFragment"
android:layout_alignParentBottom="true"
android:paddingEnd="40dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/registerForm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/newUserTxt"
android:background="#drawable/register_back"
android:orientation="vertical"
android:visibility="invisible"
>
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="right"
android:paddingEnd="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"
/>
</LinearLayout>
</RelativeLayout>
and the java code for animation
Animation bottomUp = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.bottom_up);
registrationForm.startAnimation(bottomUp);
registrationForm.setVisibility(View.VISIBLE);
this is the original view
and this is an image of the problem

Related

Inserting progressbar on button click

I have this XML and I'm planning that when the login button is clicked, it disappears and the progress bar shows up. how can I do it? this is the image of the XML already made. I've tried dozen of layout edits but still cannot achieve such. I hope someone could help as soon as possible. If there are any suggestions that you can tell please do help.
<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"
android:background="#color/logregbackground"
tools:context=".Login.LoginRegister">
<ImageView
android:id="#+id/mainformBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:src="#drawable/darkbackground" />
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="#drawable/isalonlogowithoutbackground"
android:id="#+id/mainformLogo"
android:scaleType="fitCenter"
android:layout_marginBottom="30dp"
/>
<ScrollView
android:id="#+id/scrollviewid"
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="wrap_content"
android:layout_below="#id/mainformLogo"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/trans_white_rectangle"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome to iSalon"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Style on the go, Wherever you go"
android:textColor="#color/white"
android:textSize="12sp"
android:layout_marginBottom="30dp"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Email/Username"
android:background="#drawable/rounded_white"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:drawableLeft="#drawable/ic_user_icon"
android:textSize="14sp"
android:drawablePadding="5dp"
android:paddingStart="10dp"
android:id="#+id/loginUser"
android:layout_marginBottom="10dp"
android:paddingLeft="10dp" />
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Password"
android:background="#drawable/rounded_white"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:drawableLeft="#drawable/ic_pass_icon"
android:textSize="14sp"
android:inputType="textPassword"
android:drawablePadding="5dp"
android:paddingStart="10dp"
android:id="#+id/loginPass"
android:paddingLeft="10dp" />
<Button
android:id="#+id/buttonLogin"
android:layout_width="150dp"
android:layout_height="match_parent"
android:textColor="#color/white"
android:text="Login"
android:textStyle="normal"
android:layout_gravity="center"
android:background="#drawable/login_button"
android:layout_marginTop="16dp"
android:padding="8dp"
/>
<ProgressBar
android:id="#+id/loadinglogin"
android:layout_width="124dp"
android:layout_height="27dp"
android:layout_marginLeft="100dp"
android:background="#color/white" />
<Button
android:id="#+id/buttonRegister"
android:layout_width="150dp"
android:layout_marginTop="10dp"
android:layout_height="match_parent"
android:textColor="#color/white"
android:layout_gravity="center"
android:text="Register"
android:background="#drawable/register_button"
android:padding="8dp"
android:layout_marginBottom="16dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
If you don't want the progress bar to be visible at first, you need to give it a "gone" visibility attribute in the layout (or in your onCreate code):
android:visibility="gone"
That would explain why your progress bar is visible before the login button is clicked.
If your login button isn't disappearing when it's clicked, I don't know why. You'd probably have to show your code.

ImageView as background being pushed up by opening keyboard

As I'm using png as a background for my View I didn't want it to stretch in a weird way. So I put an ImageView inside RelativeLayout and set its parametrs to match parent.
The problem appears when I click on a edittext and keyboard is opening. android:windowSoftInputMode="adjustResize" and keyboard pushes every view inside relative layout up, so my background image moves to. Do you know how to fix this?
Basically I want to adjust the view but not background image.
<?xml version="1.0" encoding="utf-8"?>
<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/login_relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:hapticFeedbackEnabled="false"
tools:context="com.example.radzik.recipes.activity.LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/background_activity_login" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:gravity="center_horizontal">
<ProgressBar
android:id="#+id/progress_bar_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<LinearLayout
android:id="#+id/login_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="#+id/progress_bar_login"
android:orientation="vertical">
<TextView
android:id="#+id/text_view_email_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="54dp"
android:layout_marginTop="15dp"
android:elevation="0dp"
android:fontFamily="#string/roboto_thin_typeface_asset_path"
android:text="EMAIL"
android:textColor="#color/white_transparent"
android:textSize="12sp" />
<EditText
android:id="#+id/edit_text_email_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:backgroundTint="#android:color/transparent"
android:fontFamily="#string/roboto_condensed_typeface_asset_path"
android:hint="example#gmail.com"
android:inputType="textEmailAddress"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white" />
<TextView
android:id="#+id/text_view_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="54dp"
android:layout_marginTop="15dp"
android:elevation="0dp"
android:fontFamily="#string/roboto_thin_typeface_asset_path"
android:text="PASSWORD"
android:textColor="#color/white_transparent"
android:textSize="12sp" />
<EditText
android:id="#+id/edit_text_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/text_view_password"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:backgroundTint="#android:color/transparent"
android:fontFamily="#string/roboto_condensed_typeface_asset_path"
android:inputType="textPassword"
android:paddingBottom="5dp"
android:paddingTop="0dp"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white"
android:textSize="30sp" />
<Space
android:layout_width="1dp"
android:layout_height="20dp" />
<Button
android:id="#+id/button_sign_in"
style="?android:textAppearanceSmall"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_sign_in"
android:onClick="onLoginClicked"
android:padding="10dp"
android:text="Log In"
android:textColor="#android:color/white"
android:textStyle="bold" />
<Space
android:layout_width="1dp"
android:layout_height="35dp" />
<!--<Button-->
<!--android:id="#+id/button_facebook_sign_in"-->
<!--style="?android:textAppearanceSmall"-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="fill_parent"-->
<!--android:background="#color/colorPrimaryDark"-->
<!--android:onClick="onFacebookLogInClicked"-->
<!--android:padding="10dp"-->
<!--android:layout_marginLeft="10dp"-->
<!--android:layout_marginRight="10dp"-->
<!--android:text="Login with Facebook"-->
<!--android:textStyle="bold"-->
<!--android:textColor="#color/colorText"/>-->
<com.facebook.login.widget.LoginButton
android:id="#+id/button_facebook_login"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textStyle="bold"
/>
<!-- <Button
android:id="#+id/button_facebook_login"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_facebook_log_in"
android:drawableLeft="#drawable/facebook_white_logo_custom_1"
android:paddingLeft="10dp"
android:paddingRight="36dp"
android:text="Facebook"
android:textColor="#android:color/white"
android:textStyle="bold" /> -->
<Space
android:layout_width="1dp"
android:layout_height="10dp" />
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
app:srcCompat="#drawable/login_bottom_coloured_line" />
<Button
android:id="#+id/button_sign_up"
style="?android:textAppearanceSmall"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#040C12"
android:onClick="onSignUpClicked"
android:padding="10dp"
android:text="SIGN UP"
android:textColor="#android:color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Background image:
background image
Try this:
Put you ImageView inside scrollview.
<ScrollView
android:id="#+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="#drawable/background_activity_login"/>
</ScrollView>
And in java set scrollview enabled false in onCreate method like below:
ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView);
scrollView.setEnabled(false);
Try not to add background in scroll view add another layout for background after scrollview it work for me

android:gravity in TextView not working

When i apply android:gravity to center(or even textAlignment true for TextView) , the instant changes are applied to current activity (using my device for testing) and the text is centered .
But then when i install/restart app with the same changes (or come back to present activity from previous one), the text is left aligned at the start of the TextView .
TextView trying to center : android:id="#+id/ttamt
The text is centered only when i make changes while running app on the activity.
Really can't understand what wrong i am doing here ,
Thanks for your time and help .
Following is my layout code :
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/mainRel"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#5f5f5f"
android:elevation="10dp"
android:transitionName="#string/transtrans">
<ImageView
android:id="#+id/ttimg"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="#drawable/com_facebook_tooltip_blue_topnub"
android:transitionName="timgTrans" />
<TextView
android:id="#+id/ttamt"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/ttimg"
android:layout_marginTop="20dp"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="1001"
android:textColor="#fff"
android:textSize="55sp"
android:textStyle="bold|italic"
android:transitionName="tamtTrans" />
<TextView
android:id="#+id/ttdate"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/ttamt"
android:layout_marginTop="25dp"
android:layout_toRightOf="#+id/timg"
android:fontFamily="sans-serif"
android:text="01/01/01"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="22dp"
android:textStyle="bold|italic" />
</RelativeLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#f0f0f0"
android:clickable="true"
android:elevation="15dp"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="7dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/ttdesc"
android:layout_width="150dp"
android:layout_height="45dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:layout_marginTop="12dp"
android:fontFamily="sans-serif"
android:text="TestDesc"
android:textSize="16sp"
android:textStyle="bold|italic"
android:transitionName="tdescTrans" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="120dp"
android:src="#drawable/ic_mode_edit_black_24dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#f0f0f0"
android:clickable="true"
android:elevation="15dp"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="7dp">
<TextView
android:id="#+id/ttmsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:lineSpacingExtra="5dp"
android:text="View SMS"
android:textSize="15dp" />
</android.support.v7.widget.CardView>
</LinearLayout>
Looks like an issue with api 18 or higher after seeing this answer.
Did the same , wrapped my views inside LinearLayout and used textAlignment="center" . Works fine now .
Final Layout Snippet :
<RelativeLayout
android:id="#+id/mainRel"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#5f5f5f"
android:elevation="10dp"
android:transitionName="#string/transtrans">
<ImageView
android:id="#+id/ttimg"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="#drawable/com_facebook_tooltip_blue_topnub"
android:transitionName="timgTrans" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:orientation="vertical">
<TextView
android:id="#+id/ttamt"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/ttimg"
android:fontFamily="sans-serif"
android:text="1001"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="55sp"
android:textStyle="bold|italic"
android:transitionName="tamtTrans" />
<TextView
android:id="#+id/ttdate"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/ttamt"
android:layout_marginTop="25dp"
android:fontFamily="sans-serif"
android:text="01/01/01"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="22dp"
android:textStyle="bold|italic" />
</LinearLayout>
</RelativeLayout>

How to create an interactive UI in android wherein the number of UI depends on the loop and put it in a scrollview

Sample UI:
In the sample UI, basic and premium are products wherein it is requested in an API. In my current code, I've designed it in my xml file only and it is not interactive. What I want to know is when the request has only one product, it will show 1 box only and if 2, 2 boxes and so on. I want to know if there's a possible way to do it not in the xml file and it should be in a scrollview. Please help me. Thanks. :)
Output should be like this:
current xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mojo="http://schemas.android.com/apk/res/com.mavshack"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/black"
android:orientation="vertical"
android:padding="1dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RelativeMain"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:gravity="center"
android:src="#drawable/mavshack_login" />
</RelativeLayout>
<com.mavshack.views.MavshackTextView
android:id="#+id/chooseplan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="#dimen/login_top_margin"
android:gravity="center"
android:text="#string/select_plan"
android:textColor="#color/mavshack_white"
android:textSize="20dp"
mojo:font_type="#integer/fnt_alrt_ttl" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/chooseplan"
android:layout_marginLeft="#dimen/got_activation_code_margin"
android:layout_marginRight="#dimen/got_activation_code_margin" >
<com.mavshack.views.MavshackTextView
android:id="#+id/basic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="10dp"
android:text="#string/plan_basic"
android:textColor="#color/mavshack_white"
android:textSize="20dp"
mojo:font_type="#integer/fnt_alrt_ttl" />
<com.mavshack.views.MavshackTextView
android:id="#+id/premium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
android:text="#string/plan_premium"
android:textColor="#color/mavshack_white"
android:textSize="20dp"
mojo:font_type="#integer/fnt_alrt_ttl" />
<LinearLayout
android:id="#+id/asd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/basic"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:id="#+id/basicRectangle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/basic"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:background="#drawable/edit_text_style"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="30dp" >
<com.mavshack.views.MavshackTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="#string/plan_HD"
android:textColor="#color/mavshack_white"
android:textSize="#dimen/fs_alrt_title"
mojo:font_type="#integer/fnt_alrt_ttl" />
<com.mavshack.views.MavshackTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="#string/plan_3Device"
android:textColor="#color/mavshack_white"
android:textSize="#dimen/fs_db_txt"
mojo:font_type="#integer/fnt_db_menu" />
<com.mavshack.views.MavshackTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="50dp"
android:gravity="center"
android:text="#string/plan_basicPrice"
android:textColor="#color/mavshack_white"
android:textSize="#dimen/fs_db_txt"
android:textStyle="bold"
mojo:font_type="#integer/fnt_db_menu" />
<com.mavshack.views.MavshackButton
android:id="#+id/basicbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_margin="5dp"
android:background="#drawable/round_button"
android:text="#string/plan_choose"
android:textColor="#color/white"
android:textSize="#dimen/fs_db_settings_paneltxt"
mojo:font_type="#integer/fnt_button_txt" />
</LinearLayout>
<LinearLayout
android:id="#+id/premiumRectangle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/premium"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:background="#drawable/edit_text_style"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="30dp" >
<com.mavshack.views.MavshackTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="#string/plan_UHD"
android:textColor="#color/mavshack_white"
android:textSize="#dimen/fs_alrt_title"
mojo:font_type="#integer/fnt_alrt_ttl" />
<com.mavshack.views.MavshackTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="#string/plan_UDevice"
android:textColor="#color/mavshack_white"
android:textSize="#dimen/fs_db_txt"
mojo:font_type="#integer/fnt_db_menu" />
<com.mavshack.views.MavshackTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="50dp"
android:gravity="center"
android:text="#string/plan_premiumPrice"
android:textColor="#color/mavshack_white"
android:textSize="#dimen/fs_db_txt"
android:textStyle="bold"
mojo:font_type="#integer/fnt_db_menu" />
<com.mavshack.views.MavshackButton
android:id="#+id/premiumbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_margin="5dp"
android:background="#drawable/round_button"
android:text="#string/plan_choose"
android:textColor="#color/white"
android:textSize="#dimen/fs_db_settings_paneltxt"
mojo:font_type="#integer/fnt_button_txt" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
yes ,make a layout inside the scroll-view and inflate child make separate
xml file which you want to inflate.and inflate from your java code
http://rajeshvijayakumar.blogspot.in/2013/03/inflating-ui-dynammically-example-in.html

Align Parent Bottom With Below RelativeLayout Android

Good day.I have an set of buttons which should be aligned to the bottom always,but they all also should be below an text,and it goes like this,if text is large,it is going just to push the buttons inside the scrollview,otherwise the buttons should be aligned to the parent bottom.Issue is that i add both of the tags to the linear layout wrapper of the buttons,but as soon as i set visibility of text to gone,the view just pops up and not aligning to parent bottom,here is the actual code,
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/single_product_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/single_product_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:src="#drawable/img_placeholder" />
<RelativeLayout
android:id="#+id/basket_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_divider"
android:layout_alignEnd="#+id/single_product_divider"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/basket_success_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:layout_marginLeft="26dp"
android:src="#drawable/success_icon" />
<TextView
android:id="#+id/basket_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/basket_success_icon"
android:layout_marginLeft="16dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/basket_success_icon"
android:text="#string/product_added_to_basket_text"
android:textColor="#ffffff"
android:textSize="16sp" />
</RelativeLayout>
<View
android:id="#+id/single_product_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/single_product_image"
android:layout_margin="25dp"
android:background="#D1D3D4">
</View>
<TextView
android:id="#+id/single_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_divider"
android:text="#string/loading_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_weight_and_servings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_name"
android:layout_marginTop="5dp"
android:text="#string/weight_and_servings_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_weight_and_servings"
android:layout_alignStart="#+id/single_product_weight_and_servings"
android:layout_below="#+id/single_product_weight_and_servings"
android:layout_marginTop="15dp"
android:text="$12.09"
android:textColor="#009444"
android:textSize="17sp"
android:textStyle="bold" />
<RatingBar
android:id="#+id/single_product_rating"
style="#style/Base.Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_price"
android:layout_alignStart="#+id/single_product_price"
android:layout_below="#+id/single_product_price"
android:layout_marginTop="5dp"
android:numStars="5" />
<TextView
android:id="#+id/single_product_rating_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating"
android:text="10.0/10"
android:textColor="#231F20"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_review_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating_text"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating_text"
android:text="8 reviews"
android:textColor="#EC2027"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_stock_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/single_product_review_count"
android:layout_marginRight="10dp"
android:text="In stock"
android:textColor="#939598" />
<View
android:id="#+id/single_product_center_divider"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/single_product_rating"
android:layout_centerHorizontal="true"></View>
<Spinner
android:id="#+id/single_product_weight_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="10dp"
android:layout_marginRight="2dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<Spinner
android:id="#+id/single_product_type_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="2dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_type_spinner"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<RelativeLayout
android:id="#+id/single_product_buttons_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="#string/add_to_cart_text"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_add_to_cart_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_info_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_nutritional_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_nutritional_info_button"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_reviews_text"
android:textAllCaps="false"
android:textColor="#231F20" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Can anyone please give any suggestion?
Edit : The full code of the view,actual buttons are inside RelativeLayout at the bottom of xml files there are 4 of buttons.The wrapper is single_product_buttons_wrapper
Add android:gravity="bottom" to LinearLayout containing buttons. It will work have tested it.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:gravity="bottom"
android:orientation="vertical">
Try this:
<?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="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_info_button"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="123"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_nutritional_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="234"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_reviews_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="5555"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="99999"
android:textAllCaps="false"
android:textColor="#231F20" />
</LinearLayout>
</RelativeLayout>

Categories

Resources