What if the screen doesn't show as I made it when I ran the app on Android Studio?

Asked 2 years ago, Updated 2 years ago, 21 views

I organized the screen like this.

It's okay until the build, but if you run it on your phone,

What's the reason for this? It's frustrating

android

2022-09-21 16:23

1 Answers

When you create a layout, don't drag-end the view, but study the characteristics of the layout (linear layout, frame layout, relational layout, etc.) and code it.

I roughly made it with the layout of the attached picture

<?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:gravity="center"
android:padding="40dp">
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"
    android:orientation="horizontal"
    android:gravity="center">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="20dp"
        android:text="Button1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:text="Button1"/>


</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"
    android:orientation="horizontal"
    android:gravity="center">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="20dp"
        android:text="Button1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:text="Button1"/>


</LinearLayout>

<TextView
    android:layout_margin="50dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="sample"/></LinearLayout>


2022-09-21 16:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.