Imagebutton not showing in Android Emulator - java

I have a problem whose solution I am unable to find out. I am creating an imagebutton thorugh Android SDk and although it shows in Preview window it does not show in Nexus 6 Emulator. The image is attached here
Code for xml file is
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".ViewActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="#dimen/activity_bold_textsize"
/>
<ImageButton
android:id="#+id/imageButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:src="#tools:sample/avatars" />
<CheckBox
android:id="#+id/checkBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/rememberMe" />
<RadioGroup
android:id="#+id/radio_g1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/rad1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rad1"/>
<RadioButton
android:id="#+id/rad2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rad2"
/>
</RadioGroup>
<ToggleButton
android:id="#+id/toggleButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/togb1" />
<Switch
android:id="#+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/Switch" />
</LinearLayout>

You do not known the diffenrence between tools and android.
tools:src="#tools:sample/avatars" is only show on preview of IDE.
Change to
android:src="#tools:sample/avatars"
Check the document: https://developer.android.com/studio/write/tool-attributes

Cause of, You are used tools:src attribute instead of android:src.
tool:<attributes> = Working only in preview emulator. It just show you Temporary hint.
android:<attributes> = Used for the actual definition that you have defined
for Ex. If you use tool:text within textView. It's only shown like hint as how looks applied theme.

Related

Align Bitmap Image inside ImageView - CS50 Pokedex Android

I have been working on CS50 and now I am tracking android. I almost finished my PSet Pokedex, but small thing is bothering me.
I am trying to align bitmap image on top of ImageView, but I could not do it. Could you please help me? I tried "scaletype", "layout_gravitiy" etc. But it does not seem to work. I want image to be just below description stating that this should be changed by the java code.
Please see current view here
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".PokemonActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pokemon_name"
android:textAlignment="center"
android:textSize="18dp"
android:textStyle="bold"
android:paddingTop="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pokemon_number"
android:textAlignment="center"
android:textSize="16dp"
android:paddingTop="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pokemon_type1"
android:textAlignment="center"
android:textSize="16dp"
android:paddingTop="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pokemon_type2"
android:textAlignment="center"
android:textSize="16dp"
android:paddingTop="5dp" />
<Button
android:id="#+id/pokemon_button_catch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:paddingTop="5dp"
android:textSize="24dp"
android:onClick="toggleCatch"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pokemon_description"
android:textAlignment="center"
android:textSize="16dp"
android:textStyle="bold|italic"
android:paddingTop="50dp"
android:text="This is testing something, this should changed by the java code."/>
<ImageView
android:id="#+id/pokemon_avatar"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Welcome to StackOverFlow !
If there is no special requirement than no need to use match_parent inside ImageView. You can do following adjustment-
<LinearLayout 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=".PokemonActivity">
..............
<ImageView
android:id="#+id/pokemon_avatar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Happy coding !
sorry. I was roasting snow in a furnace. I found out that actually source image is one to blame. Image size does not wrap the content but it has extra space around content. This is the reason when it is enlarged, there is space between text and image.

Linear layout, doesnt appear as wanted

So basically kinda new to android studio and I've gotten stuck at this problem which takes too much time..
As the title says and the image I'm providing - The outcome that I want doesnt match..
The "x" is supposed to be my personal info later on. I want the emulator to look like as the left picture.
Any help is appreciated.
I got everything to work except the theme "DarkactionBar".
Here's my code.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="parent"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteY="71dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:adjustViewBounds="true"
tools:srcCompat="#tools:sample/avatars" />
<TextView
android:id="#+id/CvIntro"
style="#style/Mitt_CV_STIL"
android:layout_width="284dp"
android:layout_height="wrap_content"
android:text="#string/CvIntro" />
<Button
android:id="#+id/Button1"
style="#style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:onClick="TillCV"
android:text="#string/button1"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
The problem is here
tools:srcCompat="#tools:sample/avatars"
tools namespace is used only for design-time purpose, read here
https://developer.android.com/studio/write/tool-attributes
You have change your colors.xml under res/values folder. In colors.xml you need to change colorPrimary, colorPrimaryDark, colorAccent etc as per your required colors.
where colorPrimary is the toolbar color, and color accent is view items color.
You can replace your xml layout from the code below.
Hope this will help
I got everything to work except the theme "DarkactionBar".
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:adjustViewBounds="true"
tools:srcCompat="#tools:sample/avatars" />
<TextView
android:id="#+id/CvIntro"
android:layout_width="284dp"
android:layout_height="wrap_content"
android:text="#string/CvIntro" />
<Button
android:id="#+id/Button1"
style="#style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:onClick="TillCV"
android:text="#string/button1"
/>
</LinearLayout>

Constraint errors in Java Android Studio

I could only find one thread pertaining to this and the answers didn't help fix the error. I am using a fresh install of Android Studio on a new laptop if that matters (maybe I need to install something that isn't currently there).
Error: This view is not constrained, it only has design time positions, so it will jump to (0,0) unless you add constraints
Edit2: It seems the new version of Android Studio doesn't use relative layout? I've tried manually changing the code as per this thread (How to switch from the default ConstraintLayout to RelativeLayout in Android Studio 2.3.3). Still not working.
Edit:
Here is an example of the code from a previous project (as you can see, this is different from my actual current code):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.squirreloverlord.ccarringtonphonephotoprint.MainActivity">
Below is my code for the main activity that is giving me the above error x4 (button/textView x2/radiogroup).
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:context="com.example.mercenaryferret.ccarrington1_currency.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_title"
android:textSize="24sp"
android:textStyle="bold|italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.032" />
<EditText
android:id="#+id/editText_usd"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/us_label"
android:inputType="numberDecimal"
android:textAlignment="center"
android:textSize="12sp"
tools:layout_editor_absoluteX="17dp"
tools:layout_editor_absoluteY="69dp"
/>
<RadioGroup
android:id="#+id/radioGrp"
android:layout_width="213dp"
android:layout_height="100dp"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="122dp"
>
<RadioButton
android:id="#+id/radioButtonEuro"
android:layout_width="98dp"
android:layout_height="wrap_content"
android:text="#string/euro_label"
tools:layout_editor_absoluteX="110dp"
tools:layout_editor_absoluteY="203dp" />
<RadioButton
android:id="#+id/radioButtonCanada"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/canada_label" />
<RadioButton
android:id="#+id/radioButtonMexico"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/mex_label" />
</RadioGroup>
<Button
android:id="#+id/buttonConvert"
android:layout_width="368dp"
android:layout_height="wrap_content"
android:text="#string/convert_label"
android:textAlignment="center"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="248dp" />
<TextView
android:id="#+id/textViewResults"
android:layout_width="316dp"
android:layout_height="31dp"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="354dp"
/>
Thank you in advance.
First of all at component tree there is ConstraintLayout left click on it and popup list opens then follow this :-
Constraint Layout >> clear all constraints then
Constraint Layout >> Add Infer Constraints
You need to add some missing constraints, here is how to do that.
Go to the Design View
Right click on your Widget
Click "Constraint Layout"
Click "Infer Constraint"
If above does not work, try below.
Go to the Design View
Right click on your Widget
Clear All Constraints
Click "Constraint Layout"
Click "Infer Constraint"
When you are using ConstraintLayout you must constraint your views both vertically and horizontally or else they may jump to the corner of your screen at run time.
After you constraint, your views as I said it will be placed according to your constraint and be relative to your screen - and your views won't jump in runtime.
Example to this layout using constraintLayout:
<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">
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="app_title"
android:textSize="24sp"
android:textStyle="bold|italic"
app:layout_constraintBottom_toTopOf="#+id/editText_usd"
app:layout_constraintEnd_toStartOf="#+id/guideline4"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.032" />
<EditText
android:id="#+id/editText_usd"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:hint="us_label"
android:inputType="numberDecimal"
android:textAlignment="center"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="#+id/radioGrp"
app:layout_constraintEnd_toStartOf="#+id/guideline4"
app:layout_constraintStart_toStartOf="#+id/guideline3"
app:layout_constraintTop_toBottomOf="#+id/textView8" />
<RadioGroup
android:id="#+id/radioGrp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="#+id/buttonConvert"
app:layout_constraintEnd_toStartOf="#+id/guideline4"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/guideline3"
app:layout_constraintTop_toBottomOf="#+id/editText_usd">
<RadioButton
android:id="#+id/radioButtonEuro"
android:layout_width="98dp"
android:layout_height="wrap_content"
android:text="euro_label" />
<RadioButton
android:id="#+id/radioButtonCanada"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="canada_label" />
<RadioButton
android:id="#+id/radioButtonMexico"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="mex_label" />
</RadioGroup>
<Button
android:id="#+id/buttonConvert"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="convert_label"
android:textAlignment="center"
app:layout_constraintBottom_toTopOf="#+id/textViewResults"
app:layout_constraintEnd_toEndOf="#+id/editText_usd"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/editText_usd"
app:layout_constraintTop_toBottomOf="#+id/radioGrp" />
<TextView
android:id="#+id/textViewResults"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="some text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/buttonConvert"
app:layout_constraintStart_toStartOf="#+id/buttonConvert"
app:layout_constraintTop_toBottomOf="#+id/buttonConvert" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.05" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.95" />
</androidx.constraintlayout.widget.ConstraintLayout>

Detect if the phone is old / NEXUS4 to avoid display issues

It looks like some issues appears on the display of my app when I run it on old devices. Here is what I observe.
1) When I open my app in recent phones (above NEXUS 5) the screen of the dialog I am showing appear properly all the elements are there. They are all defined with a height of "WRAP_CONTENT".
2) When I run my app in NEXUS 4, the dialog appears cut, even though there is still space on the screen...For whatever reason it looks like the "WRAP_CONTENT" does not work... but if I set the height of the dialog programmaticaly then it is working (I try setup the height of the button and the framelayout without success).
Any idea what I am missing there? If you advise me to set the height programmaticaly, then my problems become how to know if the user is using an old device or not so that when he is I define the pop-up taking the whole screen otherwise not...
I have included a screenshot of what I see on recent phone (just below, you can see the button cool completely) and what I see on NEXUS4 (second screenshot you can only see the beginning of the button cool...)
and below is the XML I am using
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/popup_swiperewards_flMainwindow"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_margin="32dp"
android:id="#+id/popup_swiperewards_llMaincontainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:background="#DD000000">
<TextView
android:id="#+id/popup_swiperewards_tvUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="USER NAME"
android:textColor="#android:color/white"
android:textStyle="bold" />
<ImageView
android:id="#+id/popup_swiperewards_ivSeparator1"
android:scaleType="fitXY"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/stripe_separator" />
<pro.appus.takemeout.ui.views.ViewPagerWrapContent
android:id="#+id/popup_swiperewards_vpAwardcontainer"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/popup_swiperewards_cpiCircleindicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:fillColor="#FFFFFF"
app:pageColor="#android:color/transparent"
app:radius="6dp"
app:strokeColor="#FFFFFF"
app:strokeWidth="1dp" />
<ImageView
android:id="#+id/popup_swiperewards_ivSeparator2"
android:scaleType="fitXY"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/stripe_separator" />
<TextView
android:id="#+id/popup_swiperewards_tvComeagain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Come again tomorrow \n to collect %d TMO"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textStyle="bold" />
<FrameLayout
android:id="#+id/popup_swiperewards_btnCoolContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/popup_swiperewards_btnCool"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:includeFontPadding="true"
android:background="#drawable/appsettings_button_silver"
android:text="Cool"
android:textAllCaps="true"
android:textColor="#android:color/white" />
</FrameLayout>
</LinearLayout>
</FrameLayout>
I found the mistake, it was in the code there where the margin was too big for that screen...
<LinearLayout
**android:layout_margin="32dp"**
android:id="#+id/popup_swiperewards_llMaincontainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:background="#DD000000">

Android UI using XML (Android and Xml)

I am tying to create a UI like the image below.
This is how it SHOULD look like: (Screen shot from my app using Nexsus 5):
And this is how it look like on a Nexsus S device (4 inch):
Someone have an idea why the diffrences happen? This is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2e2e2e"
tools:context=".MainActivity"
android:id="#+id/viewew">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="9"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginBottom="0dp"
android:layout_weight="8"
android:gravity="center_vertical"
>
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="15" />
<Button
android:id="#+id/www"
android:layout_weight="2"
android:layout_width="90dp"
android:layout_height="90dp"
android:background="#drawable/www"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="15" />
<Button
android:id="#+id/www"
android:layout_weight="2"
android:layout_width="90dp"
android:layout_height="90dp"
android:background="#drawable/www"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="15" />
<Button
android:id="#+id/www"
android:layout_weight="2"
android:layout_width="90dp"
android:layout_height="90dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#drawable/www"
/>
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="15" />
</LinearLayout>
<View
android:id="#+id/idd"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_alignParentBottom="true"
android:layout_weight="2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_centerHorizontal="true"
android:text="Doesn't belong here?"
android:layout_alignParentBottom="true"
/>
</LinearLayout>
<include layout="#layout/buttons" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_centerHorizontal="true"
android:text=" here?"
android:paddingBottom="15dp"
android:layout_alignParentBottom="true"
android:textColor="#f7f7f7"
android:id="#+id/tDoesntBelongHere"
/>
<com.lorentzos.flingswipe.SwipeFlingAdapterView
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rotation_degrees="15.5"
android:layout_above="#+id/eee"
tools:context=".MyActivity" />
</RelativeLayout>
On android studio you have to set the screen size for different devices.
your buttons have this:
android:layout_width="90dp"
android:layout_height="90dp"
So whichever screen you are using the size will always be 90dp.
In android studio you can create more xml pages for same page: one for portrait, for landscape, ecc ecc and also one for small-big-xxl ecc screen.
Have a look at this link from android developer site.
Hope it help :)
EDIT:
At the moment i don't have Android studio in the pc i'm working on, so i try to explain a possible solution.
Instead of setting height and width, set margins:
You can anchor all from botside, adding in your TextView android:layout_alignParentBottom="true" (and a margin-bottom if you want). Then keep your view with a static height of 400dp like now, then anchor it to the top of the TextView by android:layout_above="#id/TextViewId (it doesn't have id, add it)
Now you have to do the same with your LinearLayout: use android:layout_above="#id/idd and removing the the static size. At this point you can just let your buttons to set height equals to the LinearLayout's height (obiouvsly you can set margin top-bot in buttons).
Sorry if my english is not that good, i hope u got the solution

Categories

Resources