Search code examples
androidandroid-linearlayout

Android Button in LinearLayout Fit Left


I want to do

I want to put button like above picture. But I have below image. I can't success this. Search a lot of but can't find it.

result of code

LinearLayout in LinearLayout has transparent background and there is button left of this.

Activity.xml :

<?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="@drawable/genel_arkaplan"
android:orientation="vertical" >

<LinearLayout
    android:orientation="vertical"
    android:layout_width="750dp"
    android:layout_height="wrap_content"
    android:paddingLeft="40dp"
    android:layout_gravity="center_vertical|center_horizontal"
    android:background="@drawable/lay_transparan_aramasecenek"
    android:layout_marginTop="100dp">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/lay_transparan_aramasecenek_beyaz">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitCenter"
        android:background="@drawable/kod_ile_arama"
        android:id="@+id/imageButton" />
    </LinearLayout>
</LinearLayout>


Solution

  • remove android:paddingLeft="40dp from LinearLayout Tag