мой LinearLayout Textview и ... не оставаться на месте в разных телефонах - PullRequest
0 голосов
/ 06 марта 2019

Я создаю LinearLayout, и у него есть фоновое изображение, это нормально в размере Nexus4 в визуальной части в Android Studio, но когда я пытаюсь проверить на моем мобильном телефоне, TextView и EditText и кнопка перемещается !! и не оставаться на месте,

Я думаю, что EditText и ... не смогли автоматически заполнить мобильную страницу.

и я не буду использовать макет ограничения

(извините, я плохо говорю по-английски)

в андроид студии в реальном телефоне

мои коды:

<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"
android:background="@drawable/mane"
tools:context="com.team.programmer.secret.MainActivity">

<TextView
    android:textColor="#252525"
    android:layout_marginLeft="82dp"
    android:layout_marginTop="65dp"
    android:text="پرداخت اینترنتی تجارت الکترونیک پارسیان"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="30dp">

    <TextView
        android:layout_marginLeft="18dp"
        android:layout_marginTop="12dp"
        android:textColor="#ffffff"
        android:text="مبلغ قابل پرداخت   ۵۰۰۰ ریال"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_marginLeft="111dp"
        android:textColor="#ffffff"
        android:layout_marginTop="12dp"
        android:text="اطلاعات کارت"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="45dp">


    <EditText
        android:id="@+id/cardnum"
        android:layout_marginTop="10dp"
        android:inputType="number"
        android:layout_marginLeft="23dp"
        android:layout_width="230dp"
        android:layout_height="wrap_content" />

    <View
        android:layout_width="40dp"
        android:layout_height="20dp"></View>

    <TextView
        android:textColor="#000000"
        android:layout_marginTop="6dp"
        android:text="شماره کارت"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="40dp">


    <EditText
        android:id="@+id/pass"
        android:layout_marginTop="5dp"
        android:inputType="number"
        android:layout_marginLeft="23dp"
        android:layout_width="230dp"
        android:layout_height="wrap_content" />

    <View
        android:layout_width="58dp"
        android:layout_height="20dp"></View>

    <TextView
        android:textColor="#000000"
        android:layout_marginTop="0dp"
        android:text="رمز دوم"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="40dp">


    <EditText
        android:id="@+id/cvv2"
        android:layout_marginTop="5dp"
        android:inputType="number"
        android:layout_marginLeft="23dp"
        android:layout_width="230dp"
        android:layout_height="wrap_content" />

    <View
        android:layout_width="62dp"
        android:layout_height="20dp"></View>

    <TextView
        android:textColor="#000000"
        android:text="CVV2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="40dp">


    <EditText
        android:id="@+id/saal"
        android:layout_marginTop="5dp"
        android:inputType="number"
        android:layout_marginLeft="60dp"
        android:layout_width="85dp"
        android:layout_height="wrap_content" />

    <EditText
        android:id="@+id/maah"
        android:layout_marginTop="5dp"
        android:inputType="number"
        android:layout_marginLeft="23dp"
        android:layout_width="85dp"
        android:layout_height="wrap_content" />

    <View
        android:layout_width="39dp"
        android:layout_height="20dp"></View>

    <TextView
        android:textColor="#000000"
        android:text="تاریخ انقضا"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
    android:layout_marginTop="3dp"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="40dp">


    <EditText
        android:layout_marginTop="5dp"
        android:inputType="number"
        android:layout_marginLeft="138dp"
        android:layout_width="90dp"
        android:layout_height="wrap_content" />

    <View
        android:layout_width="72dp"
        android:layout_height="20dp"></View>

    <TextView
        android:textColor="#000000"
        android:text="کد امنیتی"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="40dp">


    <EditText
        android:layout_marginTop="5dp"
        android:inputType="number"
        android:layout_marginLeft="23dp"
        android:layout_width="230dp"
        android:layout_height="wrap_content" />

    <View
        android:layout_width="26dp"
        android:layout_height="20dp"></View>

    <TextView
        android:textColor="#000000"
        android:text="ایمیل اختیاری"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="40dp">


   <Button

       android:textColor="#ffffff"
       android:background="@drawable/selector_btn"
       android:shadowColor="#0f8129"
       android:text="پرداخت"
       android:layout_marginLeft="164dp"
       android:id="@+id/button"
       android:layout_width="70dp"
       android:layout_height="36dp" />


</LinearLayout>

<LinearLayout
    android:layout_marginTop="25dp"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="20dp">

    <TextView
        android:layout_marginLeft="153dp"
        android:textColor="#ffffff"
        android:text="اطلاعات پذیرنده"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="20dp">

    <TextView
        android:textColor="#ffffff"
        android:text="گروه برنامه نویسی secret"
        android:layout_width="153dp"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_marginLeft="151dp"
        android:textColor="#ffffff"
        android:text="نام فروشگاه:"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="20dp">

<TextView
    android:layout_marginLeft="20dp"
    android:textColor="#ffffff"
    android:text="256738813"
    android:layout_width="153dp"
    android:layout_height="wrap_content" />

<TextView
    android:layout_marginLeft="136dp"
    android:textColor="#ffffff"
    android:text="کد پذیرنده:"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
 </LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="20dp">

    <TextView
        android:layout_marginLeft="20dp"
        android:textColor="#ffffff"
        android:text="5000ریال"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_marginLeft="189dp"
        android:textColor="#ffffff"
        android:text="مبلغ قابل پرداخت:"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</LinearLayout>


</LinearLayout>

1 Ответ

0 голосов
/ 06 марта 2019
<?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:background="@android:color/white"
    android:layout_height="match_parent">

    <TextView
        android:textColor="#252525"
        android:text="پرداخت اینترنتی تجارت الکترونیک پارسیان"
        android:textAlignment="center"
        android:layout_marginTop="30dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


    <LinearLayout
        android:orientation="horizontal"
        android:layout_marginTop="20dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_weight="1"
            android:text="مبلغ قابل پرداخت   ۵۰۰۰ ریال"
            android:layout_width="match_parent"
            android:textAlignment="center"
            android:layout_height="match_parent" />

        <TextView
            android:text="اطلاعات کارت"
            android:layout_weight="1"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>


    <LinearLayout
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <EditText
            android:id="@+id/cardnum"
            android:inputType="number"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"/>

        <TextView
            android:textColor="#000000"
            android:layout_marginTop="6dp"
            android:text="شماره کارت"
            android:layout_weight="2"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <EditText
            android:id="@+id/pass"
            android:inputType="number"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"/>

        <TextView
            android:textColor="#000000"
            android:layout_marginTop="6dp"
            android:text="رمز دوم"
            android:layout_weight="2"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/cvv2"
            android:inputType="number"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp" />

        <TextView
            android:textColor="#000000"
            android:text="CVV2"
            android:layout_weight="2"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>


    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <EditText
            android:id="@+id/saal"
            android:inputType="number"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"/>

        <EditText
            android:id="@+id/maah"
            android:inputType="number"
            android:layout_weight="1"
            android:layout_marginRight="10dp"
            android:layout_marginLeft="10dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:textColor="#000000"
            android:text="تاریخ انقضا"
            android:layout_weight="1"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <View
            android:layout_width="match_parent"
            android:layout_height="10dp"
            android:layout_weight="1"></View>

        <EditText
            android:inputType="number"
            android:layout_weight="1"
            android:layout_marginRight="10dp"
            android:layout_marginLeft="10dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:textColor="#000000"
            android:text="کد امنیتی"
            android:layout_weight="1"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <EditText
            android:inputType="number"
            android:layout_width="match_parent"
            android:layout_weight="1"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"
            android:layout_height="wrap_content" />

        <TextView
            android:textColor="#000000"
            android:text="ایمیل اختیاری"
            android:layout_marginTop="6dp"
            android:layout_weight="2"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>


    </LinearLayout>

    <Button
        android:textColor="#ffffff"
        android:backgroundTint="@android:color/holo_green_dark"
        android:shadowColor="#0f8129"
        android:text="پرداخت"
        android:layout_marginTop="5dp"
        android:id="@+id/button"
        android:layout_gravity="center"
        android:layout_width="150dp"
        android:layout_height="wrap_content" />

    <TextView
            android:textColor="#ffffff"
            android:layout_marginTop="5dp"
            android:text="اطلاعات پذیرنده"
            android:layout_width="match_parent"
            android:textAlignment="center"
            android:layout_height="wrap_content" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_weight="1"
            android:textColor="#000000"
            android:text="secret"
            android:layout_marginLeft="30dp"
            android:textAlignment="textStart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:textColor="#000000"
            android:text="کد پذیرنده:"
            android:layout_weight="1"
            android:layout_marginRight="30dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_weight="1"
            android:textColor="#000000"
            android:text="256738813"
            android:layout_marginLeft="30dp"
            android:textAlignment="textStart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:textColor="#000000"
            android:text="کد پذیرنده:"
            android:layout_weight="1"
            android:textAlignment="viewEnd"
            android:layout_marginRight="30dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_weight="1"
            android:textColor="#000000"
            android:text="256738813"
            android:layout_marginLeft="30dp"
            android:textAlignment="textStart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:textColor="#000000"
            android:text="کد پذیرنده:"
            android:layout_weight="1"
            android:textAlignment="viewEnd"
            android:layout_marginRight="30dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>


</LinearLayout>

Это желаемый результат

И я предлагаю вам проверить эту ссылку Это может быть полезно

https://developer.android.com/guide/topics/ui/layout/linear

Надеюсь, это поможет:)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...