7
I have the following xml code in Android Studio:
<?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"
xmlns:tools = "http://schemas.android.com/tools"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical"
android:weightSum = "1">
<ImageView
app:srcCompat = "@mipmap/logon_img"
android:id = "@+id/imageView"
android:layout_gravity = "center_horizontal"
android:contentDescription="@string/app_name"
android:layout_width = "match_parent"
android:layout_weight = "0.38"
android:layout_height = "100dp"/>
<TextView
android:id = "@+id/login"
android:layout_gravity = "center_horizontal"
android:textSize = "30sp"
android:textAlignment = "center"
android:textStyle = "normal|bold"
android:textColor = "@color/Red"
android:text = "@string/typeUserName"
android:layout_weight = "0.00"
android:layout_width = "350dp"
android:layout_height = "wrap_content"/>
<EditText
android:layout_height = "wrap_content"
android:inputType = "textPersonName"
android:ems = "10"
android:id = "@+id/account"
android:layout_gravity = "center_horizontal"
android:textAlignment = "center"
android:textSize = "20sp"
android:layout_width = "300dp"
tools:ignore = "LabelFor"/>
<TextView
android:text = "@string/password"
android:layout_width = "350dp"
android:layout_height = "wrap_content"
android:id = "@+id/textView2"
android:layout_weight = "0.00"
android:layout_gravity = "center_horizontal"
android:textSize = "30sp"
android:textAlignment = "center"
android:textStyle = "normal|bold"
android:textColor = "@color/Red"/>
<EditText
android:layout_width = "300dp"
android:layout_height = "wrap_content"
android:inputType = "textPassword"
android:ems = "10"
android:id = "@+id/password"
android:layout_gravity = "center_horizontal"
android:textAlignment = "center"
android:textSize = "20sp"
tools:ignore = "LabelFor"/>
<Button
android:text = "@android:string/ok"
android:layout_height = "wrap_content"
android:id = "@+id/button"
android:layout_gravity = "center_horizontal"
android:layout_width = "200dp"
android:textSize = "20sp"
/>
</LinearLayout>
The component in question is Imageview, it simply does not appear in the emulator or on my phone, however, there is an empty space reserved for it on the screen. I searched the problem several times and in the vast majority of them was the huge size of the image, which is not my case because its size is 256x256. Follow a screenshot of the emulator and layout.
minSdkVersion 19
targetSdkVersion 25
com.android.support:appcompat-v7:25.0.0
I tested your layout and it was correctly displayed. Enter in the question which is the min,max and target api and the appcompat version.
– ramaral
Although I find no justification for this try to replace
app:srcCompat = "@mipmap/logon_img"
forandroid:src = "@mipmap/logon_img"
.– ramaral
android:src
was the solution @ramaral, mt thanks! agr I’ll look for why this happens– Iago Coutinho Campos
Please reply to my first comment, add the Android version of the device/emulator you tested. This will help to find a justification.
– ramaral
I changed the question, see if that’s what you need to know or if you need any more information.
– Iago Coutinho Campos
No, you are using recent versions. I find no explanation, it should work with any of the attributes.
– ramaral