First of all look at the image
I want to the text near the "Google" image fill the empty area under the google image, look the area under the google image (in above pic) is empty and text arent filling up there.
how can i do that?
XML FILE :::
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/allbg">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView8"
android:layout_gravity="center_horizontal"
android:background="#drawable/newstop" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Name Label -->
<!-- Input Name -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/slidebg"
android:id="#+id/slidebg"
android:layout_margin="7dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="70dp"
android:id="#+id/imgad2"
android:visibility="visible"
android:layout_marginTop="9dp"
android:layout_marginBottom="6dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="6dp"
/>
</RelativeLayout>
<TableLayout android:id="#+id/TableLayout01" android:stretchColumns="*"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_centerInParent="true" android:layout_below="#+id/slidebg"
android:layout_margin="5dp">
<TableRow android:id="#+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="0px" android:layout_weight="1" >
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnshare"
android:background="#drawable/opbg"
android:text="Share"
android:paddingLeft="20dp"
android:paddingTop="4dp"
android:textSize="19dp"
android:textColor="#cccccc"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btncopy"
android:background="#drawable/opbg"
android:text="Copy"
android:paddingLeft="20dp"
android:paddingTop="3dp"
android:textSize="19dp"
android:textColor="#cccccc"/>
</LinearLayout>
</TableRow></TableLayout>
<!-- Price Label -->
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- Button Create Product -->
<Button android:id="#+id/btnSave"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save Changes"
android:layout_weight="1"
android:visibility="gone" />
<!-- Button Create Product -->
<Button android:id="#+id/btnDelete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Delete"
android:layout_weight="1"
android:visibility="gone" />
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Price"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip"
android:textSize="17dip"
android:visibility="gone" />
<!-- Input Price -->
<EditText android:id="#+id/inputPrice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_marginBottom="15dip"
android:singleLine="true"
android:inputType="numberDecimal"
android:visibility="gone" />
<!-- Description Label -->
<!-- Input description -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/listrowbg"
android:id="#+id/card_view4"
card_view:cardCornerRadius="4dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_below="#+id/TableLayout01">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/titcon">
<TextView
android:id="#+id/tvname"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="6dip"
android:paddingLeft="6dip"
android:textSize="16dp"
android:textColor="#fafafa"
android:textDirection="ltr"
android:textStyle="bold"
android:maxWidth="200dp"
android:width="200dp"
android:phoneNumber="false"
android:text="Abadi - SohMj"
android:layout_marginTop="-4dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/newshead"
android:id="#+id/titsp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/titcon">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="این متن خبر تست است!"
android:id="#+id/tvdes"
android:maxLines="90"
android:ellipsize="end"
android:textSize="18dp"
android:singleLine="false"
android:textDirection="rtl"
android:textColor="#fcf8f8f8"
android:layout_weight="0.95"
android:maxLength="20000"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toRightOf="#+id/linearLayout2"
android:layout_toEndOf="#+id/linearLayout2"
android:weightSum="1"/>
<LinearLayout
android:layout_width="130dp"
android:layout_height="130dp"
android:gravity="left|top"
android:id="#+id/linearLayout2"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:clickable="false">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/image"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="تمامی اخبار و نوشته ها حق رپفارسی می باشد و هرگونه کپی پیگرد دارد."
android:id="#+id/textView2"
android:layout_gravity="center_horizontal"
android:layout_below="#+id/card_view4"
android:textColor="#fff"
android:textSize="14dp"
android:gravity="center"
android:textStyle="bold"
android:layout_marginTop="5dp" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
Use this library for wrapping your text around image..
https://github.com/deano2390/FlowTextView
Give the number in the attribute in xml
android:maxLength="100"
You can do that by setting a Max Limit to your TextView
...
android:layout_height="wrap_content" //your ImageView Height
android:maxLines="1" //Number of Lines you need to limit
android:maxLength="10" //character limit
android:ellipsize="end"
..
..
Please try this,
android:maxLength="12"
Related
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).
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:
how can i put image view to right of row of a list view?(square with image to right of row)
I hope that you can help me!
Thanks in advance everybody!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
this is my XML:
<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="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chk_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical"
android:layout_weight="1" >
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/chk_box"
android:textStyle="bold"
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/caratteristica"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_toRightOf="#id/chk_box"
android:textStyle="italic" />
</LinearLayout>
<!-- <TextView
android:id="#+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic"/>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/dist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/caratteristica"
android:layout_toRightOf="#id/chk_box"
android:textSize="12sp"
android:textStyle="italic" />
<TextView
android:id="#+id/valuta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic" />
</LinearLayout>
<EditText
android:layout_width="196dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText"
android:hint="quantità"
>
</EditText>
</LinearLayout>
</LinearLayout>
AND THIS IS PIC:
try this may be it helps you
<?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:orientation="horizontal"
>
<ImageView
android:background="#drawable/iconsmile"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:id="#+id/checkBox" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="I am here for you"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView1" />
<TextView
android:text="I am here for you"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2" />
<TextView
android:text="I am here for you"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
</LinearLayout>
</LinearLayout>
Update Your Row to add image in right in center in
I used the image of launcher you use what u take...
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chk_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical"
android:layout_weight="1" >
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/chk_box"
android:textStyle="bold"
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/caratteristica"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_toRightOf="#id/chk_box"
android:textStyle="italic" />
</LinearLayout>
<!-- <TextView
android:id="#+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic"/>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/dist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/caratteristica"
android:layout_toRightOf="#id/chk_box"
android:textSize="12sp"
android:textStyle="italic" />
<TextView
android:id="#+id/valuta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic" />
</LinearLayout>
<EditText
android:layout_width="196dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText"
android:hint="quantità"
>
</EditText>
</LinearLayout>
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_gravity="center"
android:src="#mipmap/ic_launcher"
/>
</LinearLayout>
I have this 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:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="66dp"
android:layout_height="64dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/office_girl" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/greetingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hi Boss,"
android:textStyle="bold" />
<TextView
android:id="#+id/dailyStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What to say if someone call?" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<!-- android:layout_gravity="center" -->
<EditText
android:id="#+id/suto_sms_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:hint="Text"
android:inputType="textMultiLine"
android:lines="3" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_phone_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Phone Status"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner_phone_status"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_busy_until"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="until"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Button
android:enabled="true"
android:id="#+id/button_set_date_and_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="30dp"
android:text="#string/set_time" />
<TextView
android:enabled="true"
android:id="#+id/text_date_and_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="40dp"
android:textSize="12sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="#string/button_confirm" />
<Button
android:id="#+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:text="#string/button_cancel" />
</LinearLayout>
</LinearLayout>
This is part of the output:
My question is how to align my Confirm and Cancel buttons (last part of the xml) to buttom of the screen?
I saw examples of how it can be done using relative layout, but my xml is quite big and i dont want to have to change it to relative layout as it will mean lots of work.
Thanks.
Try this code
<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:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="66dp"
android:layout_height="64dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/greetingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hi Boss,"
android:textStyle="bold" />
<TextView
android:id="#+id/dailyStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What to say if someone call?" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<!-- android:layout_gravity="center" -->
<EditText
android:id="#+id/suto_sms_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:hint="Text"
android:inputType="textMultiLine"
android:lines="3" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_phone_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:text="Phone Status"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner_phone_status"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_busy_until"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:text="until"
android:textSize="20sp" />
<Button
android:id="#+id/button_set_date_and_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="3dp"
android:enabled="true"
android:text="set_time" />
<TextView
android:id="#+id/text_date_and_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="3dp"
android:enabled="true"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.025"
android:baselineAligned="true"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="confirm" />
<Button
android:id="#+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="cancel" />
</LinearLayout>
And here your using lot of LinearLayouts but personally i recommend you to try out relativelayout
Use the android:layout_gravity="bottom" attribute on the buttons as well as their containing LinearLayout.
Add
android:layout_weight="1"
in second last LinearLayout and
android:layout_weight="0"
in last LinearLayout. Hope this work for you.
It's actually very easy to use the RelativeLayout, because you can be very smart about it. For example, wrap it around everything, so that your current parent linear layout will be the first child, end put the linear layout with the buttons at outside of the current parent with the parameter alignParentBottom
Please see 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="66dp"
android:layout_height="64dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/plus" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/greetingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hi Boss,"
android:textStyle="bold" />
<TextView
android:id="#+id/dailyStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What to say if someone call?" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<!-- android:layout_gravity="center" -->
<EditText
android:id="#+id/suto_sms_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:hint="Text"
android:inputType="textMultiLine"
android:lines="3" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_phone_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Phone Status"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner_phone_status"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_busy_until"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="until"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Button
android:enabled="true"
android:id="#+id/button_set_date_and_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="30dp"
android:text="set_time" />
<TextView
android:enabled="true"
android:id="#+id/text_date_and_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="40dp"
android:textSize="12sp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<Button
android:id="#+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="confirm" />
<Button
android:id="#+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:text="cancel" />
</LinearLayout>
</RelativeLayout>
I have the following XML code (partial for this example purposes):
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="0dp"
android:paddingRight="0dp" >
<RadioGroup
android:id="#+id/rgVehicle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.5" >
<RadioButton
android:id="#+id/rbCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Car" />
<RadioButton
android:id="#+id/rbTruck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Truck" />
<RadioButton
android:id="#+id/rbCycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Motorcycle" />
</RadioGroup>
<EditText
android:id="#+id/etToll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:layout_weight=".5" />
</LinearLayout>
For smaller screen like Galaxy Nexus and Nexus One the layout comes out like this:
How do I fix it so the EditText is directly below the #6 label as shown below (no matter what size the screen is):
There you go:
<?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="wrap_content" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5. Vehicle type"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioGroup
android:id="#+id/rgVehicle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/rbCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Car" />
<RadioButton
android:id="#+id/rbTruck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Truck" />
<RadioButton
android:id="#+id/rbCycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Motorcycle" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6. Total amount"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/etToll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
</LinearLayout>
</LinearLayout>
Use something like this:
<tablelayout>
<tablerow android:layout_weightsum="2">
<textview android:layout_weight="1" android:text="4">
<textview android:layout_weight="1" android:text="6">
</tablerow>
<tablerow android:layout_weightsum="2">
<radiogroup android:layout_weight="1">
<!-- add radio buttons here -->
</radiogroup>
<edittext android:layout_weight="1" >
</tablerow>
</tablelayout>