9 patch background force to center content

201 Views Asked by At
  • If I use 9 patch background drawable in my layout content is centered. If I use normal layout drawable Is displayed correctly based on xml.

  • If I use 9 patch drawable background in my layout, in Android Studio in design screen the content is viewed correctly but when I run the application on a device the content is centered.

  • In addition to the problem of content being centered, there is also the problem that the width of the content is limited as can see in the image.

  • Is view of list view child

  • I want it look like in the XML (the content of the layout is not centered + no content width limitted)

In device:

enter image description here

In xml:

enter image description here

Xml:

<?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:background="@null"
    android:layout_height="match_parent">


    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/imageView16"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginBottom="10dp"
        android:src="@mipmap/unknown"
        android:layout_alignBottom="@+id/relativeLayout17"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="6dp"
        android:layout_marginStart="6dp" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_marginTop="10dp"
        android:layout_height="wrap_content"
        android:background="@drawable/chatleft"
        android:id="@+id/relativeLayout17"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/imageView16"
        android:layout_toEndOf="@+id/imageView16">


        <TextView
            android:id="@+id/textView83"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:padding="7dp"
            android:text="asdasd asd as" />

    </RelativeLayout>

</RelativeLayout>

GetView:

public View getView(int position, View view, ViewGroup parent) {

    view = inflator.inflate(R.layout.chatitem, null);
    return view;
}
0

There are 0 best solutions below