I'm having some issues with align my button to the bottom of my layout. Look this picture:
As you can see I need this 5 button to be at the bottom of my layout. How can I do that? I tried layout gravity to bottom but it doesn't work. This is my code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/background_light"
android:orientation="vertical"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="80">
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="25"
android:layout_marginTop="20dp"
android:text="- How much wood would a woodchuck chuck if a woodchuck could chuck wood?"
android:textAppearance="?android:attr/textAppearanceSmall"
android:background="#android:color/holo_blue_dark"
android:paddingTop="20dp"
android:paddingLeft="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="bottom">
<Button
android:id="#+id/btnA"
android:layout_height="60dp"
android:text="YOLO"
android:maxHeight="60dp"
android:minHeight="60dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:background="#android:color/background_dark"
android:layout_margin="10dp" />
<Button
android:id="#+id/btnB"
android:text=" asda sdas dasd asd asasdasdaCiaoaga gaerg aergae gr earg aerg aerg "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:layout_height="match_parent"
android:background="#android:color/background_dark"
android:layout_margin="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="bottom">
<Button
android:id="#+id/btnC"
android:layout_height="60dp"
android:text="James Bond"
android:maxHeight="60dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:minHeight="60dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:background="#android:color/background_dark"
android:layout_margin="10dp" />
<Button
android:id="#+id/btnD"
android:layout_height="60dp"
android:text="Dunno"
android:maxHeight="60dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:minHeight="60dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:background="#android:color/background_dark"
android:layout_margin="10dp" />
</LinearLayout>
<Button
android:text="Change"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/btnCambia"
android:background="#android:color/holo_orange_dark" />
you can add them to a different layout and set
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom"
Add an empty view between textview's linearlayout and buttons' linear layout like this :
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
Put your main linearlayout tag in a relativelayout and then set alignparentbottom as true for the linearlayout.
Related
I implemented a barcode scanner in our Xamarin app. To implement the scanner I followed this tutorial: https://www.c-sharpcorner.com/article/xamarin-android-qr-code-reader-by-mobile-camera/
So, I have a SurfaceView, a CameraSource and a BarcodeDetector. Now I want to crop the camera preview to say the scanner where the barcode in which we have to scan because it is possible that the source from which we can have more than one barcode.
I think this will work with Simple Crop View (or something similar) but I don't how to implement it.
All solutions found here are not working or I'm missing something.
Do you want to acheve it like this GIF?
If so, you could achieve it with ZXing.Net.Mobile
https://github.com/Redth/ZXing.Net.Mobile
There is my demo
https://github.com/851265601/Scanebarcode
Update: If you still want to use the solution like the blew link
https://www.c-sharpcorner.com/article/xamarin-android-qr-code-reader-by-mobile-camera/
I changed the layout like following code. I usd FramLayout, SurfaceView was coverd by other raylout just like LinearLayout or relativelayout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<SurfaceView
android:id="#+id/cameraView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:background="#953399ff"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="330dp"
android:orientation="horizontal">
<RelativeLayout
android:background="#953399ff"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
<RelativeLayout
android:id="#+id/rlscan"
android:layout_width="220dp"
android:layout_height="fill_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/area_above_left" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/area_above_right" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:src="#drawable/area_below_left" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="#drawable/area_below_right" />
</RelativeLayout>
<RelativeLayout
android:background="#953399ff"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
<RelativeLayout
android:background="#953399ff"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:id="#+id/txtResult"
android:layout_below="#+id/cameraView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please focus Camera to QR Code"
android:textSize="10sp"
android:layout_marginTop="20dp" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
Xamarin Android
I'm trying make slidedown menu.
I don't know, what i'm doing wrong.
I can't position textView like i want.
View should be on the top of screen. However, it's on the bottom.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px"
android:background="#f2f2f2">
<RelativeLayout
android:id="#+id/productTitleBar"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="#ff46a1e1">
<TextView
android:id="#+id/txtProductTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:text="Product List"
android:layout_gravity="center"
android:clickable="true"
android:layout_centerVertical="true"
android:textSize="18dp"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<TextView
android:id="#+id/txtDescription"
android:layout_width="match_parent"
android:layout_height="100dp"
android:textColor="#000000"
android:text="Desription goes here"
android:layout_gravity="center"
android:clickable="true"
android:textSize="18dp"
android:layout_above="#+id/btnImgExpander"
android:background="#FFFFFF"
android:gravity="center"
android:visibility="gone" />
<ImageView
android:id="#+id/btnImgExpander"
android:layout_alignParentBottom="true"
android:layout_height="30dp"
android:layout_width="match_parent"
android:src="#drawable/up_arrow"
android:background="#fff2f2f2" />
<ListView
android:id="#+id/productListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="55dp"
android:layout_marginBottom="30dp"
android:background="#android:color/background_light"
android:fastScrollEnabled="true" />
</RelativeLayout>
I have
I want
Someone can help me with this problem?
android:layout_above="#+id/btnImgExpander" is set on the TextView, but android:layout_alignParentBottom="true" is set on the ImageView, which is aligning it to the bottom of the container (the outer RelativeLayout). You could try: android:layout_alignParentTop="true" and remove the android:layout_alignParentBottom="true"
I have a recyclerView displaying a list of imageView(thumbnail size) and textView. Whenever i populate my textViews with lot of text, the imageView is shrinked and the height increases. The textView is also wrapped to the left leaving lot of white space on the right. Below is an image of what i am talking about. How can i make the thumbnail width and height fixed even though my textView has a lot of texts, so as to maintain the image quality.
*axml**
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/card_view"
android:background="#E2E2E2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
card_view:cardCornerRadius="7dp"
android:layout_marginRight="4dp"
android:layout_marginLeft="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="25"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:id="#+id/imageView" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="63"
android:orientation="vertical"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:paddingTop="7dp"
android:paddingBottom="7dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
android:textColor="#333333"
android:text="Caption"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:id="#+id/txt_title"
android:textStyle="bold"
android:fontFamily="Times New Roman"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_vertical|left" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="14sp"
android:textColor="#333333"
android:text="Caption"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:id="#+id/textView"
android:fontFamily="Times New Roman"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_vertical|left" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="13sp"
android:textColor="#808080"
android:text="Caption"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:id="#+id/pub_date"
android:fontFamily="Times New Roman"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_vertical|left" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</android.support.v7.widget.CardView>
Refer to this javadoc for setMaxWidth method of ImageView:
An optional argument to supply a maximum width for this view. Only
valid if setAdjustViewBounds(boolean) has been set to true. To set an
image to be a maximum of 100 x 100 while preserving the original
aspect ratio, do the following:
1) set adjustViewBounds to true
2) set
maxWidth and maxHeight to 100
3) set the height and width layout
params to WRAP_CONTENT.
Note that this view could be still smaller than 100 x 100 using this
approach if the original image is small. To set an image to a fixed
size, specify that size in the layout params and then use
setScaleType(android.widget.ImageView.ScaleType) to determine how to
fit the image within the bounds.
Step 1: Remove this line:
android:weightSum="100"
Step 2: Change 63 to 1 in this line:
android:layout_weight="63"
Step 3: Change the following lines:
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="25"
to this ones:
android:layout_width="wrap_content"
android:layout_height="match_parent"
or if you want fixed width:
android:layout_width="150dp"
android:layout_height="match_parent"
Use this
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/card_view"
android:background="#E2E2E2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
card_view:cardCornerRadius="7dp"
android:layout_marginRight="4dp"
android:layout_marginLeft="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100">
<ImageView
android:layout_width="0dp"
**android:layout_height="wrap_content"**
android:layout_weight="25"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="#mipmap/ic_launcher"
android:id="#+id/imageView" />
<LinearLayout
android:layout_width="0dp"
**android:layout_height="wrap_content"**
android:layout_weight="63"
android:orientation="vertical"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:paddingTop="7dp"
android:paddingBottom="7dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
android:textColor="#333333"
android:text="Captionjkdhka asdgasidga sgdia g Caption vCaptionCaptionCaptionvCaptionCaption"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:id="#+id/txt_title"
android:textStyle="bold"
android:fontFamily="Times New Roman"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_vertical|left" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="14sp"
android:textColor="#333333"
android:text="Caption"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:id="#+id/textView"
android:fontFamily="Times New Roman"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_vertical|left" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="13sp"
android:textColor="#808080"
android:text="Caption"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:id="#+id/pub_date"
android:fontFamily="Times New Roman"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_vertical|left" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
Issue was with height of your image view and layout
Currently i'm developing a mobile application that shows some values (they will never change, so they are saved in a List). When i'm designing the page in the designer with device 4.7 WXGA i have much space to the bottom but on my real phone (Motorola Moto G3) there is no space.
Now i worry about what happens if i deploy the app on different phones (Samsung, etc). I always thought the advantage of creating a UI with something like AXML makes the app "responsive" in a meaning that it fits to the device which it is running on. But why is this not happening?
May someone give me a hint how to archieve this?
Edit:
Here is my AXML Code - for here i replaced the real text with Text
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1"
android:layout_marginTop="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2"
android:layout_margin="5dp"
android:gravity="center">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/linearLayout6">
<ImageView
android:layout_width="32dp"
android:layout_height="40dp"
android:id="#+id/imgLeft"
android:src="#drawable/arrow_left"
android:layout_marginRight="50dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/linearLayout5"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/tbDin"
android:textSize="35dp"
android:layout_marginRight="15dp"
android:textColor="#android:color/black" />
<TextView
android:layout_width="60dp"
android:layout_height="match_parent"
android:id="#+id/tbDinWert"
android:textSize="35dp"
android:textColor="#android:color/black"
android:gravity="center"
android:text="XX" />
<ImageView
android:layout_width="32dp"
android:layout_height="40dp"
android:id="#+id/imgRight"
android:src="#drawable/arrow_right"
android:layout_marginLeft="50dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout3"
android:background="#android:color/transparent"
android:layout_marginTop="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb1"
android:textSize="16dp"
android:layout_marginRight="142dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:inputType="none"
android:textColor="#android:color/black"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb2"
android:textSize="16dp"
android:layout_marginRight="142dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:inputType="none"
android:textColor="#android:color/black"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb3"
android:textSize="16dp"
android:layout_marginRight="142dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:inputType="none"
android:textColor="#android:color/black"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb3"
android:textSize="16dp"
android:layout_marginRight="142dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:inputType="none"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb4"
android:textSize="16dp"
android:layout_marginRight="142dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:inputType="none"
android:textColor="#android:color/black"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb5"
android:textSize="16dp"
android:layout_marginRight="142dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:textColor="#android:color/black"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb6"
android:textSize="10dp"
android:layout_marginRight="142dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:textColor="#android:color/black"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:background="#android:color/transparent"
android:paddingLeft="15dp">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:id="#+id/tb7"
android:textSize="10dp"
android:textColor="#android:color/black"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="142dp"
android:gravity="center" />
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/TextView4"
android:textSize="35dp"
android:background="#android:color/transparent"
android:textColor="#android:color/black"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Ok, so first you cannot use same ids for views like linearLayout4. Second, correct practise is best practise so insted of creating so many layouts, create header and ListView and then populate it. Weather you have 3 item or 333 use ListView.
Next thing dont use android:layout_marginRight="142dp" like this. Margin and padding should be much smaller and for acheaving efect of streaching items use something like this:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout4"
android:layout_margin="5dp"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="16dp"
android:textColor="#android:color/black"
android:text="Value"
android:layout_weight="0.5"
android:gravity="center"/>
<TextView
android:text="Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="35dp"
android:textColor="#android:color/black"
android:layout_weight="0.5"
android:gravity="center"/>
</LinearLayout>
You can paste it to see the result.
Try to practise design in program that u are creating your app. If you are using AndroidStudio it has preview so you can check diferent size of screens.
And for any layout or view if you set android:layout_width="match_parent" android:layout_height="match_parent" it will always fit to the device.
Try creating layouts and view, with different background, while changing height and width so you can see what is happening.
You have to keep in mind that devices have different screen sizes and different densities. Don't set your pixel sizes in px, but in sp for fonts(scaleable pixels). For other things, use dp instead of px
You have to handle multiple screen sizes by creating layout-ldpi, mdpi, hdpi, xhdpi. So that any screen sizes is there, look and feel will be the same across all the devices,and also font should be in "sp" and other elements in "dp".
I think that you need a full-size None-Stretched Image in your aplication with this tutorial you can adapt a image in every device without problem
https://dzone.com/articles/using-full-size-none-stretched
or this other thing if you wanna adapt your app for the type of device or OS.
The static Device class includes several properties and methods that allow your code to deal with device differences at run time in a very simple and straightforward manner:
The Device.OS property returns a member of the TargetPlatform
enumeration: iOS, Android, WinPhone, or Other. The WinPhone member
refers to all the Windows and Windows Phone platforms.
The Device.Idiom property returns a member of the TargetIdiom
enumeration: Phone, Tablet, Desktop, or Unsupported.
You can use these two properties in if and else statements, or a switch and case block, to execute code specific to a particular platform.
https://developer.xamarin.com/guides/xamarin-forms/platform-features/device/
https://forums.xamarin.com/discussion/56817/how-to-use-platform-idiom-in-xaml
and in this book you can watch a excellent example the use of Device.OnPlatform page 58.
https://developer.xamarin.com/guides/xamarin-forms/creating-mobile-apps-xamarin-forms/
I hope with this you solve your problem. Regards.
HELP
I using TableLayout & TableRow, in the picture below I trying to marge No.4 and No.6 together just like No.1 however I had no idea how to do it. For no.1 I was able to do cause I just using Layout-weight to divide the screen into 3row,3col .
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*">
<TableRow
android:layout_weight="2"
android:id="#+id/tableRow1">
<TextView
android:text="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#android:color/holo_blue_dark" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="2"
android:stretchColumns="*"
android:id="#+id/tableLayout1">
<TableRow
android:layout_weight="1"
android:id="#+id/tableRow1"
android:background="#android:color/holo_red_dark">
<TextView
android:text="2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_span="2"
android:gravity="center" />
</TableRow>
<TableRow
android:layout_weight="1"
android:id="#+id/tableRow3">
<TextView
android:text="3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" />
<TextView
android:text="4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" />
</TableRow>
</TableLayout>
</TableRow>
<TableRow
android:layout_weight="1"
android:id="#+id/tableRow1">
<TextView
android:text="5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_span="2"
android:gravity="center"
android:background="#android:color/holo_green_dark" />
<TextView
android:text="6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right" />
</TableRow>
</TableLayout>
below img is the result that i wants