How to fix parsing XML: unbound prefix in android - android

I am getting an XML:Unbound prefix error in android i tried a lot but it was still occurring please make it solve as soon as possible..........................................................................................................................................................................................................................................................................................................
<RelativeLayout 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">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click" />
<pl.pawelkleczkowski.customgauge.CustomGauge
android:id="#+id/gauge3"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
app:endValue="100"
app:pointEndColor="#color/Green"
app:pointStartColor="#color/Red"
app:startAngel="180"
app:startValue="0"
app:strokeCap="BUTT"
app:strokeColor="#color/Gray"
app:strokeWidth="20dp"
app:sweepAngel="180" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/gauge3"
android:layout_centerHorizontal="true"
android:layout_marginBottom="52dp"
android:text="0"
android:textSize="30dp"
android:textStyle="bold" />
</RelativeLayout>

Change
<RelativeLayout 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">
to
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:gauge="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >

Change
<RelativeLayout 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">
to
<RelativeLayout 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">

Related

android:layout_centerHorizontal not working

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".MainActivity">
<ImageView
android:layout_height="200dp"
android:layout_width="match_parent"
android:layout_below="#id/firstview"
android:src="#drawable/paint_shop"
android:scaleType="centerCrop"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/firstview">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CHHABRA ASSOCIATES"
android:layout_centerHorizontal="true"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="#FFE033"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="#FF3333"/>
</RelativeLayout>
</RelativeLayout>
Here android:layout_centerHorizontal is not working properly. what is the reason??I have added relative layout viewgroup over text view but it is not working. I want to center the text
Try with
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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.appcompat.widget.AppCompatImageView
android:layout_height="200dp"
android:layout_width="match_parent"
android:layout_below="#id/firstview"
app:srcCompat="#drawable/icon_check_circle"
android:scaleType="centerCrop"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/firstview">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CHHABRA ASSOCIATES"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="#FFE033"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="#FF3333"/>
</RelativeLayout>
</RelativeLayout>

Is it possible to put something above listview?

Im trying to put textview above list check view and the output overlaps textview and listview which is not right.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="horizontal"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="352dp"
android:layout_marginBottom="712dp"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/checkable_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</RelativeLayout>
Thankyou for your help
Something similar:
<?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"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ListView
android:id="#+id/checkable_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Do it like this
<?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"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ListView
android:id="#+id/checkable_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

Unable to add more than one button in Linear Layout

I use Linear Layout in my code and I want to add buttons in my activity using vertical scrollbar. But I'm not able to add more than one button in android. Drag and drop is not working and also manual xml coding doesn't work either. Please help
activity_main.xml:
<?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/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/chco"
tools:context="com.example.tset.test.Prerequisites">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
Try this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/chco"
tools:context="com.example.tset.test.Prerequisites"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
Try this
activity_main.xml:
<?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/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/chco"
tools:context="com.example.tset.test.Prerequisites">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<Button
android:id="#+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Traveler Login" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Login" />
</LinearLayout>
</ScrollView>
<?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/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/chco"
tools:context="com.example.tset.test.Prerequisites">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Try this
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical"
android:background="#drawable/login_bg"
tools:context=".activities.LoginActivity">
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/submit"
android:textSize="18sp"
android:text="Login"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/submit1"
android:textSize="18sp"
android:text="Login1"/>
</LinearLayout>
</ScrollView>

RecycleView cells fill the screen

I'm following a tutorial on android programming and have run into trouble with recycleviews. The cells of the view each seem to fill a full screen of space rather than a just the information in the cell. Shown here:
activity_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.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"
android:fitsSystemWindows="true"
tools:context="com.example.moore.criminalintent.CrimeActivity">
<include layout="#layout/content_fragment" />
</android.support.design.widget.CoordinatorLayout>
content_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.moore.criminalintent.CrimeActivity"
tools:showIn="#layout/activity_fragment">
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></FrameLayout>
</RelativeLayout>
fragment_crime.xml
<?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">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/Crime_title_label"
style="?android:listSeparatorTextViewStyle"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/crime_title"
android:hint="#string/crime_title_hint"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/crime_detail_label"
style="?android:listSeparatorTextViewStyle"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/crime_date"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/crime_solved"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="#string/crime_solved_label"/>
</LinearLayout>
fragment_crime_list.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/crime_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
list_item_crime.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/list_item_crime_solved_check_box"
android:layout_alignParentRight="true"
android:padding="4dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/list_item_crime_title_text_view"
android:layout_toLeftOf="#id/list_item_crime_solved_check_box"
android:textStyle="bold"
android:padding="4dp"
tools:text="Crime Title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/list_item_crime_date_text_view"
android:layout_toLeftOf="#id/list_item_crime_solved_check_box"
android:layout_below="#id/list_item_crime_title_text_view"
android:padding="4dp"
tools:text="Crime Date"/>
</RelativeLayout>
I can post more code if its needed. Any help with how to fix this would be greatly appreciated.
Try this:
list_item_crime.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/list_item_crime_solved_check_box"
android:layout_alignParentRight="true"
android:padding="4dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/list_item_crime_title_text_view"
android:layout_toLeftOf="#id/list_item_crime_solved_check_box"
android:textStyle="bold"
android:padding="4dp"
tools:text="Crime Title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/list_item_crime_date_text_view"
android:layout_toLeftOf="#id/list_item_crime_solved_check_box"
android:layout_below="#id/list_item_crime_title_text_view"
android:padding="4dp"
tools:text="Crime Date"/>
</RelativeLayout>

No Touch feedback on recyclerview when using ripple effect library

Here is my main xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"></include>
<android.support.v4.widget.DrawerLayout
android:layout_below="#+id/tool_bar"
android:id="#+id/DrawerLayout"
android:elevation="7sp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tool_bar"
android:text="#string/hello_world" />
<android.support.v7.widget.RecyclerView
android:id="#+id/RecycleView"
android:layout_width="288dp"
android:background="#ffffff"
android:layout_height="match_parent"
android:layout_gravity="left"
android:scrollbars="vertical"
android:focusable="true"
android:clickable="true">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Here is my item_row.xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rowIcon"
android:paddingLeft="16dp"
android:src="#drawable/ic_launcher"/>
<com.balysv.materialripple.MaterialRippleLayout
android:id="#+id/ripple"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/rowText" />
</com.balysv.materialripple.MaterialRippleLayout>
</LinearLayout>
I am using the libray https://github.com/balysv/material-ripple
When I am not using the library the click is working fine but when using the library I did not receive any touch feedback.
Please help me on this.
Try to wrap your item_row.xml with the MaterialRippleLayout. Basically set it as your parent layout to receive the click from the user. Try this:
<?xml version="1.0" encoding="utf-8"?>
<com.balysv.materialripple.MaterialRippleLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/ripple"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mrl_rippleColor="#80000000"
app:mrl_rippleOverlay="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rowIcon"
android:paddingLeft="16dp"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/rowText" />
</LinearLayout>
</com.balysv.materialripple.MaterialRippleLayout>

Categories

Resources