Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android layout – Is the below xml file right?

Posted on November 11, 2022 By

Solution 1 :

Try to use this layout:

   <androidx.constraintlayout.widget.ConstraintLayout
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    tools_layout_editor_absoluteX="0dp"
    tools_layout_editor_absoluteY="0dp">

    <androidx.constraintlayout.widget.Guideline
        android_id="@+id/guideline"
        android_layout_width="0dp"
        android_layout_height="wrap_content"
        android_orientation="horizontal"
        app_layout_constraintGuide_percent="0.2" />

    <TextView
        android_id="@+id/textView2"
        android_layout_width="0dp"
        android_layout_height="0dp"
        android_text="1"
        android_textSize="20sp"
        android_textStyle="bold"

        app_layout_constraintBottom_toBottomOf="@+id/btndelete1"
        app_layout_constraintDimensionRatio="1:1"
        app_layout_constraintEnd_toEndOf="parent"
        app_layout_constraintHorizontal_bias="0.2"
        app_layout_constraintStart_toStartOf="parent"
        app_layout_constraintTop_toTopOf="@+id/btndelete1"
        app_layout_constraintVertical_bias="0.3" />

    <TextView
        android_id="@+id/semester"
        android_layout_width="0dp"
        android_layout_height="wrap_content"
        android_text="2"
        app_layout_constraintBottom_toBottomOf="@+id/textView2"
        app_layout_constraintDimensionRatio="1:1"
        app_layout_constraintEnd_toEndOf="parent"
        app_layout_constraintHorizontal_bias="0.15"
        app_layout_constraintStart_toEndOf="@+id/textView2"
        app_layout_constraintTop_toTopOf="@+id/textView2"
        app_layout_constraintVertical_bias="0.3"
        app_layout_constraintWidth_percent="0.1" />

    <TextView
        android_id="@+id/textView32"
        android_layout_width="0dp"
        android_layout_height="wrap_content"
        android_text="SGPA"
        app_layout_constraintBottom_toTopOf="@+id/guideline"
        app_layout_constraintDimensionRatio="1:1"
        app_layout_constraintEnd_toEndOf="@+id/textView2"
        app_layout_constraintHorizontal_bias="0.2"
        app_layout_constraintStart_toStartOf="@+id/textView2"
        app_layout_constraintTop_toBottomOf="@+id/textView2"
        app_layout_constraintVertical_bias="0.7"
        app_layout_constraintWidth_percent="0.1" />

    <TextView
        android_id="@+id/textView33"
        android_layout_width="0dp"
        android_layout_height="0dp"
        android_text="Percentage"
        app_layout_constraintBottom_toBottomOf="@+id/textView32"
        app_layout_constraintEnd_toStartOf="@+id/btndelete1"
        app_layout_constraintHorizontal_bias="0.6"
        app_layout_constraintStart_toEndOf="@+id/semester"
        app_layout_constraintTop_toTopOf="@+id/textView32"
        app_layout_constraintVertical_bias="0.70"
        app_layout_constraintWidth_percent="0.18" />

    <TextView
        android_id="@+id/textV"
        android_layout_width="0dp"
        android_layout_height="wrap_content"
        android_text="3"
        app_layout_constraintBottom_toBottomOf="@+id/textView32"
        app_layout_constraintDimensionRatio="1:1"
        app_layout_constraintEnd_toEndOf="@+id/semester"
        app_layout_constraintHorizontal_bias="0.08"
        app_layout_constraintStart_toStartOf="@+id/semester"
        app_layout_constraintTop_toTopOf="@+id/textView32"
        app_layout_constraintVertical_bias="0.0"
        app_layout_constraintWidth_percent="0.1" />

    <TextView
        android_id="@+id/textVw"
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_text="5"
        app_layout_constraintBottom_toBottomOf="@+id/textView33"
        app_layout_constraintEnd_toStartOf="@+id/btndelete1"
        app_layout_constraintHorizontal_bias="0.08"
        app_layout_constraintStart_toEndOf="@+id/textView33"
        app_layout_constraintTop_toTopOf="@+id/textView33" />

    <TextView
        android_id="@+id/scheme1"
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_text="4"
        android_textSize="10sp"
        app_layout_constraintEnd_toEndOf="@+id/btndelete1"
        app_layout_constraintStart_toStartOf="@+id/btndelete1"
        app_layout_constraintTop_toTopOf="@+id/guideline" />

    <ImageButton
        android_id="@+id/btndelete1"
        android_layout_width="0dp"
        android_layout_height="wrap_content"
        app_layout_constraintBottom_toBottomOf="parent"
        app_layout_constraintDimensionRatio="1:1"
        app_layout_constraintEnd_toEndOf="parent"
        app_layout_constraintHorizontal_bias="0.96"
        app_layout_constraintStart_toStartOf="parent"
        app_layout_constraintTop_toTopOf="parent"
        app_layout_constraintVertical_bias="0.05"
        app_layout_constraintWidth_percent="0.1"
        app_srcCompat="@android:drawable/ic_menu_delete" />

</androidx.constraintlayout.widget.ConstraintLayout>

I have used those attributes to make your layout responsive:

app:layout_constraintGuide_percent="0.2" 
app_layout_constraintDimensionRatio="1:1"

In addition, I added Guideline

And it will look like this:

enter image description here

Problem :

Is the below xml file right? I am trying to display information that I have fetched from sqlite in recycler view.

Is the below xml file right? I am trying to display information that I have fetched from sqlite in recycler view.

<?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_orientation="vertical" android_layout_width="match_parent"
    android_layout_height="match_parent">

    <androidx.cardview.widget.CardView
        android_layout_width="match_parent"
        android_layout_height="150dp">

        <androidx.constraintlayout.widget.ConstraintLayout
            android_layout_width="match_parent"
            android_layout_height="match_parent">

            <TextView
                android_id="@+id/textView2"
                android_layout_width="3dp"
                android_layout_height="23dp"
                android_textSize="20sp"
                android_textStyle="bold"
                app_layout_constraintBottom_toBottomOf="parent"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.2"
                app_layout_constraintStart_toStartOf="parent"
                app_layout_constraintTop_toTopOf="parent"
                app_layout_constraintVertical_bias="0.3" />

            <TextView
                android_id="@+id/semester"
                android_layout_width="wrap_content"
                android_layout_height="wrap_content"
                app_layout_constraintBottom_toBottomOf="parent"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.15"
                app_layout_constraintStart_toEndOf="@+id/textView2"
                app_layout_constraintTop_toTopOf="parent"
                app_layout_constraintVertical_bias="0.3" />

            <TextView
                android_id="@+id/textView32"
                android_layout_width="wrap_content"
                android_layout_height="wrap_content"
                android_text="SGPA"
                app_layout_constraintBottom_toBottomOf="parent"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.2"
                app_layout_constraintStart_toStartOf="parent"
                app_layout_constraintTop_toTopOf="parent"
                app_layout_constraintVertical_bias="0.7" />

            <TextView
                android_id="@+id/textView33"
                android_layout_width="wrap_content"
                android_layout_height="wrap_content"
                android_text="Percentage"
                app_layout_constraintBottom_toBottomOf="parent"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.6"
                app_layout_constraintStart_toStartOf="parent"
                app_layout_constraintTop_toTopOf="parent"
                app_layout_constraintVertical_bias="0.70" />

            <TextView
                android_id="@+id/textV"
                android_layout_width="wrap_content"
                android_layout_height="wrap_content"
                app_layout_constraintBottom_toBottomOf="@+id/textView32"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.08"
                app_layout_constraintStart_toEndOf="@+id/textView32"
                app_layout_constraintTop_toTopOf="@+id/textView32"
                app_layout_constraintVertical_bias="0.0" />

            <TextView
                android_id="@+id/textVw"
                android_layout_width="wrap_content"
                android_layout_height="wrap_content"
                app_layout_constraintBottom_toBottomOf="@+id/textView33"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.08"
                app_layout_constraintStart_toEndOf="@+id/textView33"
                app_layout_constraintTop_toTopOf="@+id/textView33" />

            <TextView
                android_id="@+id/scheme1"
                android_layout_width="wrap_content"
                android_layout_height="wrap_content"
                android_textSize="10sp"
                app_layout_constraintBottom_toBottomOf="parent"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.95"
                app_layout_constraintStart_toStartOf="parent"
                app_layout_constraintTop_toTopOf="parent"
                app_layout_constraintVertical_bias="0.95" />

            <ImageButton
                android_id="@+id/btndelete1"
                android_layout_width="30dp"
                android_layout_height="40dp"
                app_layout_constraintBottom_toBottomOf="parent"
                app_layout_constraintEnd_toEndOf="parent"
                app_layout_constraintHorizontal_bias="0.96"
                app_layout_constraintStart_toStartOf="parent"
                app_layout_constraintTop_toTopOf="parent"
                app_layout_constraintVertical_bias="0.05"
                app_srcCompat="@android:drawable/ic_menu_delete" />

        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.cardview.widget.CardView>
</LinearLayout>

This is what I want:

READ  [FIXED] android - Kotlin - Scroll Detection issue in Recyclerview
Powered by Inline Related Posts

enter image description here

And this is what I am getting:

enter image description here

I don’t know why. Can someone help me out?

Also, if needed, this is where I am calling the recycler view:

 <?xml version="1.0" encoding="utf-8"?>

        <FrameLayout 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"
        tools_context=".drawernav.bottom_navi.recycler_view.sgpa_frag">

        <!-- TODO: Update blank fragment layout -->
        <androidx.recyclerview.widget.RecyclerView
            android_id="@+id/rc1"
            android_layout_width="wrap_content"
            android_layout_height="wrap_content">

        </androidx.recyclerview.widget.RecyclerView>

        <TextView
            android_id="@+id/else2"
            android_layout_width="match_parent"
            android_layout_height="match_parent"
            android_text="It's a bit lonely here..."
            android_gravity="center"
            android_visibility="gone"/>

    </FrameLayout>

Comments

Comment posted by MMG

What do you mean? “xml is right?”

Comment posted by Tamir Abutbul

What exactly not working, what view is not responsive?

Android Tags:android-cardview, android-constraintlayout, android-layout, android-linearlayout, android-recyclerview

Post navigation

Previous Post: [FIXED] activity_main.xml for android studio stuck on loading
Next Post: Can a beginner learn Moonlight Sonata 1st Movement?

Related Posts

[FIXED] java – Spannable text shows only for a second, when button is clicked. Why? Android
[FIXED] i have a problem with data binding in android studio Android
[FIXED] android – How to capture microphone audio on React Native and stream it to IceCast endpoint? Android
[FIXED] android – Is there a way to detect if flutter has access to internet? Android
[FIXED] java – Unable to integrate Mpesa Api into my android app Android
[FIXED] java – Only Switch.setChecked doesn’t work when fragment is shown? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What are the main features of Islamic education?
  • Is the Jeep 4xe worth it?
  • How does the ringer work on cast iron?
  • What is the biggest size interior door?
  • Is blue raspberry an original Jolly Rancher flavor?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme