android.widget.LinearLayout cannot be cast to android.widget.TextView at com.example.foodorderapp.Adapters.OrdersAdapter$viewHolder.<init>

All we need is a simple explanation of the problem, which is provided below. I’m Trying To Solve This Bug At Debugging But Couldn’t Find Its Solution Souce Code Link: Download import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.example.foodorderapp.Models.OrdersModel; import com.example.foodorderapp.R; import java.util.ArrayList; public class … Read more

How to use Coordinatorlayout with Linearlayout?

All we need is a simple explanation of the problem, which is provided below. <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout 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" tools:context=".activities.MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.google.android.material.appbar.MaterialToolbar style="@style/Widget.MaterialComponents.Toolbar.Surface" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:elevation="4dp" app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" app:title="@string/app_name" /> <androidx.fragment.app.FragmentContainerView android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" app:defaultNavHost="true" /> <com.google.android.material.bottomnavigation.BottomNavigationView android:layout_width="match_parent" android:layout_height="wrap_content" app:labelVisibilityMode="unlabeled" app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" app:menu="@menu/menu_bottom_navigation" /> </LinearLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout> This attribute app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" … Read more

Android ScrollView dissapearing the rest of my UI

All we need is a simple explanation of the problem, which is provided below. I’m new to Android layout design. My problem is that when trying to add a ScrollView to my layout it disappears the rest of my UI. In the following code, when I uncomment the ScrollView, it happens the aforementioned problem. <?xml … Read more

Layout Weight distribution wrongly interpreted

All we need is a simple explanation of the problem, which is provided below. I want to define a composite layout where the header and footer LinearLayout blocks take 10% of the view and body block the remaining 80%. Without setting weights, all 3 blocks have the same size, so I have set the weight … Read more

Why we need LinearLayout inside of CardView?

All we need is a simple explanation of the problem, which is provided below. I have following xml code from youtube: <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:gravity="center" tools:context=".MainActivity"> <androidx.cardview.widget.CardView android:layout_width="300dp" android:layout_height="300dp" app:cardElevation="10dp" app:cardCornerRadius="20dp" app:cardBackgroundColor="@color/white" tools:ignore="MissingConstraints"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:layout_height="150dp" android:layout_width="match_parent" android:src="@drawable/sandwich" android:id="@+id/sandwich" android:scaleType="centerCrop" tools:ignore="MissingConstraints" /> <TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Welcome" android:textAlignment="center" /> </LinearLayout> … Read more

Problem in some views in items row of recyclerview "not showing like disign preview"

All we need is a simple explanation of the problem, which is provided below. I trying to practice some android lessons that contains recyclerview topic, currently I succeed to implement all api and response but there’s one problem with my item_article_preview.xml the title and descreption of news doesn’t shows in emulator like it’s in desing … Read more

How to Dynamically Change LinearLayout Orientation Depending on Device Orientation

All we need is a simple explanation of the problem, which is provided below. How do I change the orientation of a LinearLayout when a device changes orientation? What changes would be needed in the *.xml’s associated *.kt file? For example, the device is in Portrait and displays a LinearLayout with a vertical orientation. When … Read more

TableLayout crushes button

All we need is a simple explanation of the problem, which is provided below. I’m experiencing a strange issue with a TableLayout next to a Button. This is the XML: <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=”match_parent” android:orientation=”horizontal”> <TableLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/tableLayout1″ android:stretchColumns=”*” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_weight=”1″ > <TableRow android:id=”@+id/tableRow1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” > <TextView android:id=”@+id/textView1″ android:text=”Column 1″ /> <Button … Read more