When I create a new project in Android studio, and choose a blank activity, there is a default Constraint Layout attached.
I'm trying to follow some online tutorials with a Grid layout, but it's not working as expected because of the constraint layout.
The tutorial is a couple years old so I'm guessing the constraint layout was part of an update.
Is it possible to get rid of this constraint layout?
Below is the default XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="com.user1.gridlayoutApp.MainActivity"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
</android.support.constraint.ConstraintLayout>
you can just remove ConstraintLayout tags and add LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<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">
</LinearLayout>
Close your IDE and then open again with the help of internet access to update it..
Related
I am getting an error Class referenced in the layout file, cn.hugeterry.coordinatortablayout.CoordinatorTabLayout, was not found in the project or the libraries while importing CoordiatorTabLayout in android studio
here screenshot of the error
<?xml version="1.0" encoding="utf-8"?>
<cn.hugeterry.coordinatortablayout.CoordinatorTabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/coordinatortablayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.prosec.Safety">
<android.support.v4.view.ViewPager
android:id="#+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</cn.hugeterry.coordinatortablayout.CoordinatorTabLayout>
You added dependency of cn.hugeterry.coordinatortablayout.CoordinatorTabLayout layout? Because this is custom Layout, not android provided Layout. You have to add the dependency to use a custom Layout. If you use the android default coordinator layout then this is not android default. The android default layout is below.
<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">
</androidx.coordinatorlayout.widget.CoordinatorLayout>
If your coordinatorLayout is android default then make your layout as above I added. If problem is same, let me know
I am trying to achieve like the image below how can i do in fragment android.libraries.places.widget i tried using relative layout but its not showing up inside the places widget can anyone suggest some good source to do it or is there any other layout which can be used to do it.
The Xml which i tried:
<?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=".Maps.MapsAddress" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginTop="10dp"
android:id="#+id/autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.libraries.places.
widget.AutocompleteSup portFragment"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chetpet Chennai"
android:textSize="14sp"
android:id="#+id/toolbar_address">
</TextView>
</FrameLayout>
Root layout use : Relative
SearchBar layout can use searchview or floating searchview(external libraries)
Device Location can use relative layout so icon place at the start of parent and etc
Saved addresses you can use table layout.
Assign id to the different layout so that you can stack the layout inside of the root-relative layout
the scrollbar in my RecyclerView doesn't work, I mean I can scroll the RecyclerView with touch, I also can see the scrollbar but it's can not move
Before ask the question I also tried with some answers here for example:
https://www.dev2qa.com/android-recyclerview-horizontal-scroll-example/
Android RecyclerView Scroll not working after Layout edit
But none of them work for me
Below is my code, thanks in advance
Layout file:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HexViewActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_hex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:scrollbarSize="15dp"
android:scrollbars="vertical" />
</ScrollView>
Code to create the view
RecyclerView recyclerView = findViewById(R.id.rv_hex);
recyclerView.setLayoutManager(new LinearLayoutManager(HexConstant.app_ontext));
m_fileDataAdapter = new FileDataAdapter(HexConstant.app_ontext, files[0]);
recyclerView.setAdapter(m_fileDataAdapter);
recyclerView.setNestedScrollingEnabled(true);
Is there any example for Scrollbar + recyclerView, pls let me know
Change the outer layout with scroll view layout.
<ScrollView
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:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HexViewActivity">
<!-- Your stuff here -->
</ScrollView>
Have you tried using RecyclerView's attribute app:fastScrollEnabled="true"?
Check the full answer here. https://stackoverflow.com/a/46026362/6455501
I am switching between text and design view in android studio and it seems that whenever I make a change in the text (xml) and the change back to design my changes are overwritten by something random. I want the text changes to take priority over the design tab.
For example:
I have this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.foo.MainActivity">
<RelativeLayout
android:layout_width="368dp"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp">
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
change it into this in text view:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.foo.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
when I switch to Design it somehow resets back to the first one. I want to see my changes even if they are wrong, without starting an emulator. I tried googling it but I can't see anybody else reporting this.
I am starting out with Xamarin studio, I have build most basic forms project. In tutorials it shows how to edit layout in Main.xml, that is supposed to be in Resources/layout that is missing in my solution. So when I add it manually it then fails with error message The layout contains malformed XML and another one Root element is missing. When I opened the Main.xml in notepad I can see contents to be <?xml version="1.0" encoding="UTF-8" ?>.
How do contents of proper blank Main.xml supposed to be like?
Review that the markups are start and close correctly; for example,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="#drawable/fondomizzou" **/>**
NOT
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="#drawable/fondomizzou"
**</RelativeLayout> />**
Figured it out myself
Click on source, then add
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
and that should do it.