0

I am new in android and i am trying to develop a application in which I am using on linear layout custom Edit text and Image View and on relative layout FAB and google Ad you see in image This is what i am trying to get for all device but when i am using small I am getting different thing which i am adding in second imageThis what I am getting in small device Please help me to achieve image 1 for all device . Thanks in Advance any Help will be Helpful for me.

This is XML code:-

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.hp.newcode.MainActivity">

 <LinearLayout
        android:id="@+id/linearlayout"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="@drawable/edittextxml"
        android:orientation="horizontal"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="13dp"
        android:layout_marginRight="13dp"
        android:layout_above="@+id/adView"
        android:layout_toLeftOf="@+id/btnQR"
        android:layout_gravity="bottom">
        <EditText
            android:layout_toLeftOf="@+id/search"
            android:id="@+id/inputSearchEditText"
            android:layout_width="220dp"
            android:paddingLeft="15dp"
            android:layout_height="match_parent"
            android:ellipsize="start"
            android:hint="Search Society"
            android:inputType="number"
            android:maxLength="10"
            android:textSize="15sp"
            android:background="@drawable/edittextxml"/>
        <LinearLayout
            android:id="@+id/imageLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:background="#275766">
            <ImageView
                android:id="@+id/search"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:clickable="true"
                android:src="@drawable/search"/>
        </LinearLayout>
    </LinearLayout>
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/btnQR"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        app:fabSize="normal"
        app:srcCompat="@drawable/ic_action_name1"
        android:scaleType="center"
        android:layout_marginRight="20dp"
        android:layout_marginEnd="9dp"
        android:layout_alignBottom="@+id/linearlayout"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true">
    </com.google.android.gms.ads.AdView>
</RelativeLayout>
intellijAI
  • 35
  • 2
  • 8

1 Answers1

0

I made a few changes in your code. hope it help: I changed view hierarchy a little. and for editText I added android:layout_weight="1" and android:layout_width="0dp so it would be responsive in all screen sizes.

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layoutDirection="ltr"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/linearlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_marginLeft="13dp"
        android:layout_marginRight="13dp"

        android:orientation="horizontal">

        <EditText
            android:id="@+id/inputSearchEditText"
            android:layout_width="0dp"
            android:layout_height="50dp"
            android:layout_gravity="center_vertical"
            android:layout_marginBottom="20dp"
            android:layout_marginTop="20dp"
            android:layout_weight="1"
            android:ellipsize="start"
            android:hint="Search Society"
            android:inputType="number"
            android:maxLength="10"
            android:paddingLeft="15dp"
            android:textSize="15sp" />

        <ImageView
            android:id="@+id/search"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="center_vertical"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="20dp"
            android:clickable="true" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/btnQR"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|end"
            android:layout_marginEnd="9dp"
            android:layout_marginRight="20dp"
            android:scaleType="center"
            app:fabSize="normal" />

    </LinearLayout>

    <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111" />
</LinearLayout>
Marzi Heidari
  • 2,660
  • 4
  • 25
  • 57
  • Thanks for help @Marzieh Heidari but sadly your code did not work for. Edit Text , Image view , FAB and Advertise is not showing at all. – intellijAI Sep 29 '17 at 06:42
  • Thanks for help again @Marzieh Heidar but still this did not solve my problem now i am getting Edit Text , Image view and FAB on above just below action bar and another problem is in image view I ma not getting image. – intellijAI Oct 04 '17 at 08:09
  • What's wrong with being Edit Text , Image view and FAB on above just below action bar? :/ And I removed all backgrounds and ImageView's src so that I coud run xml om my device.add src and editText and LinearLayout Background again :) – Marzi Heidari Oct 04 '17 at 08:32
  • Thanks Again @Marzieh Heidari your code worked perfectly . You solve my problem Thanks again. – intellijAI Oct 04 '17 at 12:50
  • Your welcome :) So mark my answer as correct one if you please :) – Marzi Heidari Oct 04 '17 at 13:34
  • hey i need another help@Marzieh Heidari can you help me – intellijAI Oct 09 '17 at 11:57
  • https://stackoverflow.com/questions/33528400/how-to-combine-one-android-studio-project-into-another-android-studio-project They answer well but i didn't get how to do. – intellijAI Oct 12 '17 at 13:31
  • Hello @Marzieh can you help me with this https://stackoverflow.com/questions/47510897/im-trying-to-access-camera-in-nougat-and-higher-versionapi-level-25-but-my-ap?noredirect=1#comment81977574_47510897 – intellijAI Nov 27 '17 at 13:36
  • Can you please answer this @ Marzieh Heidari [https://stackoverflow.com/questions/50482787/getting-this-error-while-login-at-org-json-jsontokener-syntaxerrorjsontokener/50482926?noredirect=1#comment87985374_50482926] – intellijAI May 24 '18 at 11:15
  • Hey @ Marzieh Heidari Can you please help me with this. – intellijAI Jun 06 '18 at 07:44
  • Hey @Marzieh Heidari can you answere [this](https://stackoverflow.com/questions/51980037/how-to-achieve-zigzag-view-in-middle-of-cardview) please – intellijAI Aug 23 '18 at 09:32