Android Bottom Menu with images & Text of equal Size - java

I have a requirement where there needs to be a horizontal row of buttons with different images for different tap states and text on the bottom. For the life of me, I can't figure out how to keep the aspect ratio, my button backgrounds look stretched wide.
I'm using a LinearLayout and each button has equal weight. That made the buttons equal size to each other but I wanted to keep the background image aspect ratio square. The ideal layout would be a row of square sized buttons...
I have tried this solution but it is for an ImageButton.
My main.xml looks like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:weightSum="5">
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="#drawable/menu"
android:gravity="center|bottom"
android:text="Settings" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#null" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#null" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#null" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#null" />
</LinearLayout>
And my layout looks like this, yes I realize some buttons don't have images yet. How should I fix the aspect ratio?

Your layout will be look like this :
Your Bottom Layout will be like this :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#color/gray_light1"
android:layout_alignParentBottom="true">
<include layout="#layout/home_bottom"/>
you can include this LinearLayout to your Bottom LinearLayout :
home_bottom.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/home_ll"
android:gravity="center_horizontal"
android:layout_weight="1"
android:padding="5dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground"
android:layout_height="55dp">
<ImageView
android:id="#+id/home_img"
android:background="#mipmap/ic_home"
android:layout_width="25dp"
android:layout_height="25dp" />
<TextView
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blacklike"
android:textSize="10dp"
android:text="Home"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/search_ll"
android:gravity="center_horizontal"
android:layout_weight="1"
android:padding="5dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground"
android:layout_height="55dp">
<ImageView
android:id="#+id/search_img"
android:background="#mipmap/ic_search"
android:layout_width="25dp"
android:layout_height="25dp" />
<TextView
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blacklike"
android:textSize="10dp"
android:text="Search"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/categories_ll"
android:gravity="center_horizontal"
android:layout_weight="1"
android:padding="5dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground"
android:layout_height="55dp">
<ImageView
android:id="#+id/categories_img"
android:background="#mipmap/ic_categories"
android:layout_width="25dp"
android:layout_height="25dp" />
<TextView
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blacklike"
android:textSize="10dp"
android:text="Categories"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/cart_ll"
android:gravity="center_horizontal"
android:layout_weight="1"
android:padding="5dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground"
android:layout_height="55dp">
<LinearLayout
android:gravity="center_horizontal"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/cart_img"
android:background="#mipmap/ic_cart"
android:layout_width="25dp"
android:layout_height="25dp" />
<TextView
android:gravity="center"
android:layout_marginLeft="-10dp"
android:layout_width="18dp"
android:layout_height="18dp"
android:textColor="#color/white"
android:textSize="10dp"
android:background="#mipmap/ic_cart_back"
android:text="8"
/>
</LinearLayout>
<TextView
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blacklike"
android:textSize="10dp"
android:text="Cart"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/account_ll"
android:gravity="center_horizontal"
android:layout_weight="1"
android:padding="5dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground"
android:layout_height="55dp">
<ImageView
android:id="#+id/account_img"
android:background="#mipmap/ic_account"
android:layout_width="25dp"
android:layout_height="25dp" />
<TextView
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/blacklike"
android:textSize="10dp"
android:text="Account"
/>
</LinearLayout>
</LinearLayout>

Related

complete scrollView screenshot not completely visible android

I am trying to take full scrollView screenshot of a fragment in android. What seems to be working for other doesn't work in my case. I referred to other stackoverflow questions as well. Only bottom part of the screenshot is visible and top part is missing and in the middle it is black (screenshot attached below).
Bitmap bitmap = createScreenshot(mainLinearLayout, mainLinearLayout.getChildAt(0).getHeight(), mainScrollView.getChildAt(0).getWidth());
//create bitmap from the ScrollView
private Bitmap createScreenshot(View view, int height, int width) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Drawable bgDrawable = view.getBackground();
if (bgDrawable != null)
bgDrawable.draw(canvas);
else
canvas.drawColor(Color.WHITE);
view.draw(canvas);
return bitmap;
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent">
<ProgressBar
android:id="#+id/progressBar_eco_scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="#dimen/progressbar_elevation"
android:layout_centerInParent="true"/>
<ScrollView
android:id="#+id/scrollView_ecoScan"
android:layout_width="match_parent"
android:background="#color/background_color"
android:padding="#dimen/marginPaddingSize_24sdp"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linear_layout_eco_scan_top_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- fragment title & desc -->
<com.google.android.material.card.MaterialCardView
android:id="#+id/cardView_home_plant_scan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="#dimen/card_corner_radius_default">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="#dimen/marginPaddingSize_10sdp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_5sdp"
android:text="#string/my_personal_eco_scan"
android:textSize="#dimen/textSize_header"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/garten_von"
android:textSize="#dimen/textSize_body_medium"
android:textStyle="italic" />
<TextView
android:id="#+id/text_view_eco_scan_garden_owner_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/marginPaddingSize_5sdp"
android:textSize="#dimen/textSize_body_medium"
android:textStyle="italic" />
</LinearLayout>
<TextView
android:id="#+id/text_view_eco_scan_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="0"
android:textSize="#dimen/textSize_body_medium" />
<TextView
android:id="#+id/text_view_eco_scan_about_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/marginPaddingSize_10sdp"
android:justificationMode="inter_word"
android:lines="4"
android:text="#string/eco_scan_description"
android:textSize="#dimen/textSize_body_small" />
<ImageView
android:id="#+id/expand_icon_eco_scan_desc"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end"
android:layout_marginTop="10dp"
android:src="#drawable/expand"
android:text="#string/more_details"
android:textSize="#dimen/textSize_body_medium" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:backgroundTint="#color/greenIntensity4"
app:cardCornerRadius="#dimen/card_corner_radius_default">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:padding="#dimen/marginPaddingSize_10sdp">
<TextView
android:id="#+id/text_view_eco_scan_surface_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="#dimen/marginPaddingSize_5sdp"
android:layout_weight="1"
android:lines="2"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/editText_eco_scan_surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="#dimen/marginPaddingSize_10sdp"
android:layout_marginRight="#dimen/marginPaddingSize_10sdp"
android:layout_weight="0.2"
android:inputType="numberDecimal"
android:background="#color/light_gray"
android:minWidth="#dimen/editText_min_width" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="#dimen/marginPaddingSize_5sdp"
android:text="#string/meter_squared"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:backgroundTint="#color/greenIntensity4"
app:cardCornerRadius="#dimen/card_corner_radius_default">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="#dimen/marginPaddingSize_10sdp">
<TextView
android:id="#+id/text_view_eco_scan_green_area_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="#dimen/marginPaddingSize_5sdp"
android:layout_weight="1"
android:gravity="center_vertical"
android:lines="2"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/editText_eco_scan_green_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="#dimen/marginPaddingSize_10sdp"
android:layout_marginRight="#dimen/marginPaddingSize_10sdp"
android:layout_weight="0.2"
android:inputType="numberDecimal"
android:background="#color/light_gray"
android:minWidth="#dimen/editText_min_width" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="#dimen/marginPaddingSize_5sdp"
android:text="#string/meter_squared"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
app:cardCornerRadius="#dimen/card_corner_radius_default">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/marginPaddingSize_10sdp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:text="#string/auswertung"
android:textSize="#dimen/textSize_header"
android:textStyle="bold" />
<!-- land use slider -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/land_use"
android:textAppearance="?android:textAppearanceMedium"
android:textSize="#dimen/textSize_body_medium" />
<ImageView
android:id="#+id/image_view_eco_scan_land_use_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_info"
app:tint="#color/darkGray" />
</LinearLayout>
<SeekBar
android:id="#+id/seekbar_eco_scan_land_use"
android:layout_width="fill_parent"
android:layout_height="#dimen/seek_bar_height"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:layout_marginBottom="#dimen/marginPaddingSize_10sdp"
android:max="100"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:progress="50"
android:splitTrack="false"
android:thumb="#drawable/seekbar_eco_thumb_icon" />
<!-- Eco element slider -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/eco_element"
android:textAppearance="?android:textAppearanceMedium"
android:textSize="#dimen/textSize_body_medium" />
<ImageView
android:id="#+id/image_view_eco_scan_eco_element_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_info"
app:tint="#color/darkGray" />
</LinearLayout>
<SeekBar
android:id="#+id/seekbar_eco_scan_eco_element"
android:layout_width="fill_parent"
android:layout_height="#dimen/seek_bar_height"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:layout_marginBottom="#dimen/marginPaddingSize_10sdp"
android:max="100"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:progress="50"
android:splitTrack="false"
android:thumb="#drawable/seekbar_eco_thumb_icon" />
<!-- Plant diversity slider -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/plant_diversity"
android:textAppearance="?android:textAppearanceMedium"
android:textSize="#dimen/textSize_body_medium" />
<ImageView
android:id="#+id/image_view_eco_scan_plant_diversity_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_info"
app:tint="#color/darkGray" />
</LinearLayout>
<SeekBar
android:id="#+id/seekbar_eco_scan_plant_diversity"
android:layout_width="fill_parent"
android:layout_height="#dimen/seek_bar_height"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:layout_marginBottom="#dimen/marginPaddingSize_10sdp"
android:max="100"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:progress="50"
android:splitTrack="false"
android:thumb="#drawable/seekbar_eco_thumb_icon" />
<!-- Flowering time slider -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/flowering_time"
android:textAppearance="?android:textAppearanceMedium"
android:textSize="#dimen/textSize_body_medium" />
<ImageView
android:id="#+id/image_view_eco_scan_flowering_time_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_info"
app:tint="#color/darkGray" />
</LinearLayout>
<com.github.mikephil.charting.charts.CombinedChart
android:id="#+id/combined_chart_eco_scan"
android:layout_width="match_parent"
android:layout_height="#dimen/chart_height"
android:layout_marginTop="10dp" />
<!-- legends -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="#dimen/small_icon_size"
android:layout_height="#dimen/small_icon_size"
android:src="#drawable/oko_optimum_gartengroesse_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/marginPaddingSize_10sdp"
android:text="#string/optimal_for_your_garden_size"
android:textSize="#dimen/textSize_body_small" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_5sdp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="#dimen/small_icon_size"
android:layout_height="#dimen/small_icon_size"
android:src="#drawable/oko_anzahl_meiner_bluehenden_arten_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/marginPaddingSize_10sdp"
android:text="#string/number_of_flowering_species"
android:textSize="#dimen/textSize_body_small" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_5sdp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="#dimen/small_icon_size"
android:layout_height="#dimen/small_icon_size"
android:src="#drawable/oko_optimum_erreicht_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/marginPaddingSize_10sdp"
android:text="#string/optimum_achieved"
android:textSize="#dimen/textSize_body_small" />
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/button_eco_scan_save_result_to_calendar"
style="#style/PrimaryButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/marginPaddingSize_10sdp"
android:text="#string/save_result_to_calendar" />
<com.google.android.material.button.MaterialButton
android:id="#+id/button_eco_scan_share_result"
style="#style/SecondaryButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/marginPaddingSize_24sdp"
android:text="#string/share_result" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
You should draw the content of the ScrollView (the view having id linear_layout_eco_scan_top_view) instead. The missing content is due to memory optimizations made by the ScrollView which draws only the views that fit on the screen and skips the others (you should ensure the bitmap fits in the available memory of your app before creating it to prevent an OutOfMemoryError).

How to stretch Imagview in xml layout and show other button to left of it

I'm using Relativelayout within cardview layout to show the user details. But I want to show the two button at the end with equal width on and everything in the left side of Image which will stretch from Top to bottom.
But I'm not able to do so.
here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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="wrap_content"
android:padding="5dp"
android:layout_marginBottom="2dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
>
<ImageView
android:id="#+id/contact_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#fff"
android:src="#drawable/binil"
android:padding="1dp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/top"
android:padding="5dp">
<TextView
android:id="#+id/contact_name"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Sagar Rawal"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_mobile"
android:text="9868336847"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_name"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_address"
android:layout_below="#+id/contact_name"
android:layout_width="wrap_content"
android:text="Jumla"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textStyle="bold"
android:layout_toRightOf="#+id/contact_mobile" />
<TextView
android:id="#+id/contact_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="searchbbc1881#gmail.com"
android:layout_below="#+id/contact_mobile"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<ImageButton
android:layout_below="#+id/contact_email"
android:id="#+id/call"
android:background="#drawable/shape_button"
android:layout_width="wrap_content"
android:src="#drawable/ic_call_black_24dp"
android:layout_height="wrap_content" />
<ImageButton
android:layout_toRightOf="#id/call"
android:layout_below="#+id/contact_email"
android:background="#drawable/shape_button"
android:layout_width="wrap_content"
android:src="#drawable/ic_email_black_24dp"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.v7.widget.CardView>
My output is
But I want something similar to this
Where two buttons will equally stretch to left side of Image.
Please help
Try using LinearLayout weightSum like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100">
<TextView
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:text="text1!" />
<TextView
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:text="text2!" />
</LinearLayout>
Update:
Replace your code with this, it will solve your issue
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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="wrap_content"
android:layout_marginBottom="2dp"
android:padding="5dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="1">
<RelativeLayout
android:id="#+id/top"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".7"
android:padding="5dp">
<TextView
android:id="#+id/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Sagar Rawal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/contact_name"
android:text="9868336847"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_name"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/contact_mobile"
android:text="Jumla"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/contact_mobile"
android:text="searchbbc1881#gmail.com"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:weightSum="1">
<ImageButton
android:id="#+id/call"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:layout_weight=".5"
android:background="#drawable/shape_button"
android:src="#drawable/ic_email_black_24dp"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:layout_toRightOf="#id/call"
android:layout_weight=".5"
android:background="#drawable/shape_button"
android:src="#drawable/ic_email_black_24dp"
/>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/contact_profile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:background="#fff"
android:padding="1dp"
android:src="#drawable/ic_launcher_background" />
</LinearLayout>
</android.support.v7.widget.CardView>
Try to reorganize it this way:

Change design item of GridView, how? - Android

I want to change a design of me item in GridView.
Now is:
I want this item in square shape not like it is now in rectangle.
Also, the IMG (from the screenshot) i want to have above 'Name' and every textview at the center. Is it possible? Here is my XML:
<?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:background="#color/md_brown_100"
android:orientation="vertical"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="10dp" >
<TextView
android:id="#+id/credit_wallet"
android:text="#string/hi"
android:gravity="center"
android:textColor="#color/md_brown_700"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
<com.justfashion.Logo
android:text="Fashion Wallet"
android:gravity="center"
android:textColor="#color/md_brown_700"
android:layout_marginTop="25dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
<LinearLayout android:id="#+id/list_offer_item_container"
android:layout_marginTop="15dp"
android:layout_below="#id/text"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/shape"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/txtname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="1dp"
android:textColor="#48899f"
android:textSize="#dimen/textsizeearncredit_title"
android:text="Name"
android:textAllCaps="false"
android:textStyle="normal|bold" />
<TextView
android:id="#+id/txtdesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:maxLines="1"
android:textColor="#80869c"
android:textSize="#dimen/textsizeearncredit_desc"
android:text="This is a description of the offer and this is just a demo to show off 3 lines stacking correctly on top of each other"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center_vertical">
<TextView android:id="#+id/list_offer_badge_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/list_offer_item_container"
android:textColor="#color/md_amber_700"
android:textSize="12sp"
android:visibility="gone"
android:text=""/>
</LinearLayout>
<ImageView
android:id="#+id/imgcreditcompany"
android:layout_width="42dp"
android:layout_above="#+id/txtname"
android:contentDescription="#string/app_name"
android:gravity="center"
android:layout_height="42dp" />
<ImageView
android:id="#+id/nextArrow"
android:layout_alignParentRight="true"
android:tint="#color/md_grey_300"
android:rotation="180"
android:layout_width="32dp"
android:visibility="gone"
android:layout_marginRight="16dp"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_height="32dp"
android:contentDescription="#string/app_name"
android:padding="#dimen/two" />
</LinearLayout>
</RelativeLayout>
I tried a lot of combination and don't works. Please help me guys! Thanks!
EDIT
The IMG from the screenshot is
<ImageView
android:id="#+id/imgcreditcompany"
android:layout_width="42dp"
android:layout_above="#+id/txtname"
android:contentDescription="#string/app_name"
android:gravity="center"
android:layout_height="42dp" />
In the code above

Android: How to draw 8 equal rectangles to fit screen width with XML

I'm new to JAVA and Android development.
Basically I would like to draw 8 equal rectangles (keyboard keys) to fit on 100% width.
As far as I know linearlayout doesn't support drawables, so sadly that piece of code doesn't work for me:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:weightSum="2">
<View
android:id="#+id/keyboardKey1"
android:background="#drawable/keyboard_key_white"
android:weight="1"
android:layout_width="0dip"
android:layout_height="200dp"
android:layout_alignTop="#+id/keyboardKeyC"
android:layout_toRightOf="#+id/keyboardKeyA" />
<View
android:id="#+id/keyboardKey2"
android:background="#drawable/keyboard_key_white"
android:weight="1"
android:layout_width="0dip"
android:layout_height="200dp"
android:layout_alignTop="#+id/keyboardKeyC"
android:layout_toRightOf="#+id/keyboardKeyA" />
</LinearLayout>
Here are the contents of keyboard_key_while.xml as well:
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#fff" />
<stroke
android:width="1dp"
android:color="#000" />
</shape>
As far as I know, I also can't do the the other way round and use linearlayout inside of the drawable XML. Can you give me suggestions of how to achieve that?
Thank you!
I did this before. Let me check my code to see if I still have it.
I found it. The layout I created is for a calculator. I wanted the buttons to scale according to screen size.
I used a TextView with solid white background for the buttons. I'm sure you could use a drawable for a background as well. Anyway, have a look at the way I did the LinearLayouts.
The Code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:background="#ffffffff"
>
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_weight="3"
android:background="#ffffff"
android:text="Food"
android:gravity="center|right"
android:paddingRight="0dp"
android:singleLine="true"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<RelativeLayout
android:id="#+id/more"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/layer_list_arrow_dn"
android:gravity="center"
android:singleLine="true"
android:onClick="onViewClick"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:background="#ffffffff"
>
<TextView
android:id="#+id/amount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_weight="3"
android:background="#ffffff"
android:text="0.00"
android:gravity="center|right"
android:paddingRight="0dp"
android:singleLine="true"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<RelativeLayout
android:id="#+id/clear"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/layer_list_clear"
android:gravity="center"
android:singleLine="true"
android:onClick="onViewClick"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:background="#00fcb514"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="0dp"
android:layout_marginRight="5dp"
android:background="#00333333"
>
<TextView
android:id="#+id/b00"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:background="#drawable/ripple_holo_blue_bright"
android:text="7"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="4"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="1"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b03"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="0dp"
android:background="#ffffff"
android:text=""
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#00666666"
>
<TextView
android:id="#+id/b10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="8"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="5"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="2"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="0dp"
android:background="#ffffff"
android:text="0"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#00999999"
>
<TextView
android:id="#+id/b20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="9"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b21"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="6"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b22"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:text="3"
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b23"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="0dp"
android:background="#ffffff"
android:text="."
android:gravity="center"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="0dp"
android:background="#00cccccc"
>
<TextView
android:id="#+id/b30"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:textSize="27sp"
android:textStyle="bold"
android:background="#drawable/layer_list_arrow_up"
android:onClick="onViewClick"
/>
<TextView
android:id="#+id/b31"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/layer_list_arrow_dn"
android:layout_marginTop="5dp"
android:layout_marginBottom="0dp"
android:textSize="27sp"
android:textStyle="bold"
android:onClick="onViewClick"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
You can do that with a LinearLayout set to horizontal orientation and have each view inside that set an equal layout_weight and zero layout_width. You were almost there but you have to use layout_weight instead of weight.
This shows two keys taking up the width of the screen. If you put 8 views in there it scales accordingly.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:id="#+id/keyboardKey1"
android:layout_width="0dip"
android:layout_height="200dp"
android:layout_weight="1"
android:background="#drawable/keyboard_key_white" />
<View
android:id="#+id/keyboardKey2"
android:layout_width="0dip"
android:layout_height="200dp"
android:layout_weight="1"
android:background="#drawable/keyboard_key_white" />
</LinearLayout>
Two more things
in your example you are using RelativeLayout layout parameters in the keyboard views (layout_alignTop and layout_toRightOf). However the keyboard views are being hosted by a LinearLayout and are therefore ignored so they can be left out.
Another way to do this is to use the GridLayout where you can specify how many columns and rows you want. Inside the GridLayout you specify for each child view in which column and row you want it to appear with layout_column and layout_row.
Read up on Layouts on the Android Developer API Guides.

Android LinearLayout place elements in the middle with landscape and portrait mode

My layout contains three buttons, one EditText field and one button. I want to place the three buttons in one row, but in the center (horizontal) of the screen. The EditText field should be below the buttons and below the EditText field, there should be one button.
Here is my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blueAct"
android:orientation="vertical"
android:paddingBottom="100.0dip"
android:paddingLeft="10.0dip"
android:paddingRight="10.0dip"
android:paddingTop="100.0dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="4.0dip"
android:paddingLeft="100.0dip"
android:paddingRight="100.0dip"
android:paddingTop="5.0dip" >
<ImageButton
android:id="#+id/buttonGreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="4.0dip"
android:background="#drawable/green_button"
android:contentDescription="#string/green" />
<ImageButton
android:id="#+id/buttonRed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="4.0dip"
android:background="#drawable/red_button"
android:contentDescription="#string/red" />
<ImageButton
android:id="#+id/buttonBlue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="4.0dip"
android:background="#drawable/blue_button"
android:contentDescription="#string/blue" />
</LinearLayout>
<EditText
android:id="#+id/phone_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/phone_code"
android:paddingTop="100.0dip"
android:textColor="#color/white"
android:textColorHint="#color/white" >
<requestFocus />
</EditText>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="#color/orangeAct"
android:onClick="searchUsers"
android:paddingTop="100.0dip"
android:text="#string/button_go"
android:textColor="#color/white" />
</LinearLayout>
Now the problem is, that the three buttons are not in the center if the user changes from portrait to landscape mode.
How is it possible to make this 'responsive', without creating a separate layout file for landscape mode?
Any help would be greatly appreciated.
Don't use padding on your horizontal LinearLayout to center the views. Instead you can add views before and after that expand to fill the remaining space.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageButton
android:id="#+id/buttonGreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
<ImageButton
android:id="#+id/buttonRed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
<ImageButton
android:id="#+id/buttonBlue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="#mipmap/background"
android:orientation="vertical"
android:id="#+id/homemain124"
android:weightSum="3">
<RelativeLayout
android:id="#+id/paneltamrin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="something"
android:textColor="#fff"
android:id="#+id/top1"
android:gravity="center_horizontal"
android:layout_marginTop="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:layout_marginLeft="40dp"
android:padding="8dp"
android:background="#drawable/textcorner"
android:layout_below="#+id/top1"
android:text="something"
android:textSize="20sp"
android:textColor="#fff"
android:id="#+id/top2"
android:fontFamily="monospace"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_marginTop="30dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top2"
android:text="APPLIED BY"
android:textSize="15sp"
android:id="#+id/top3"
android:textColor="#fff"
android:gravity="center_horizontal"
android:layout_marginTop="30dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top3"
android:text="COURT OF JUSTICE IN INDIA"
android:id="#+id/top4"
android:textSize="15sp"
android:textColor="#fff"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_marginTop="10dp"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/paneltamrin2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:layout_width="220dp"
android:layout_height="160dp"
android:src="#mipmap/book1"
android:id="#+id/image1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/paneltamrin3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="READ NOW"
android:textColor="#fff"
android:lineSpacingExtra="10dp"
android:textSize="20sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
android:id="#+id/buttonorder"
android:padding="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/orderbutton"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="13sp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:layout_below="#+id/buttonorder"
android:text="something"/>
</RelativeLayout>
</LinearLayout>
Linear layout added for 3 relative layouts

Categories

Resources