Android Studio 2.3 not displaying layout designs - android

I've just upgraded to Android Studio 2.3, but when I try to display this layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="#dimen/card_margin"
android:elevation="3dp"
app:cardBackgroundColor="#color/transparent"
android:background="#color/transparent"
app:cardCornerRadius="#dimen/card_album_radius">
<RelativeLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:clickable="true"
android:scaleType="fitCenter" />
<ImageView
android:id="#+id/alarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/toolbar_alarm"
android:alpha="0.35"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:paddingBottom="#dimen/songs_count_padding_bottom"
android:paddingLeft="#dimen/album_title_padding"
/>
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/songs_count_padding_bottom"
android:paddingLeft="#dimen/album_title_padding"
android:paddingRight="#dimen/album_title_padding"
android:layout_toRightOf="#id/alarm"
android:layout_alignParentBottom="true"
android:textSize="#dimen/songs_count"
tools:text="Sample Title" />
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16sp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:textColor="#color/album_title"
android:textSize="#dimen/note_card_title"
android:textStyle="normal"
/>
<ImageView
android:id="#+id/overflow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:scaleType="centerCrop"
android:src="#drawable/ic_dots" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
I receive this error from interface designer (layout editor):
The following classes could not be found:
- android.support.v7.app.WindowDecorActionBar (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.ActionBarContainer (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.ActionBarContextView (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.ActionBarOverlayLayout (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.ContentFrameLayout (Fix Build Path, Edit XML, Create Class)
Clicking on Fix Build Path or other links has no effect.

This solved my problem :
Change your style parent to Theme.AppCompat.Light.NoActionBar instead of Theme.AppCompat.Light.DarkActionBar in styles.xml......... it worked for me.
https://stackoverflow.com/a/40067731/305135

Try to check your dependencies. After update to Android Studio 2.3, my gradle broke.
See details

Related

My (Specific) layout causes Android Studio XML Layout Preview to keep on loading and not displaying the preview

I am making a layout which contains CardView and nested Linear Layouts. When I made the layout for the first time it works fine and the preview window is also displaying the changes. After a day when I open android Studio the preview window keep saying "Waiting for build to finish". So I thought that it is bug related to IDE.
I tried all the solutions that are recommended here:
Clean Project
Rebuild Invalidate Cache & restart
Delete the caches folder from Gradle
But I found out that issue was with my layout beacuse I deleted the layout rebuild the project and preview works fine again. Now I tried to make the same layout again from start but it still happens again. It is very strange for me as my layout is simple, I have created Similar layouts before with no issue whatsoever.
I am using the Latest Api Version 29, with latest build tools and latest Android Studio.
Here is my layout code:
<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:background="#color/light"
tools:context=".Ui.Setting">
<androidx.appcompat.widget.Toolbar
android:id="#+id/setting_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/light"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ToolbarTheme"
app:title="SETTINGS"
app:titleMarginStart="40dp"
app:titleTextColor="#color/dark" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/accessibility"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/setting_toolbar"
android:layout_marginStart="10dp"
android:padding="10dp"
android:text="#string/accessibility"
android:textColor="#color/dark"
android:textSize="18sp" />
<androidx.cardview.widget.CardView
android:id="#+id/accessibility_card"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/accessibility"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPadding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical">
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="#string/grey_scale" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:useMaterialThemeColors="true" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical">
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="0.5"
android:text="#string/text_size" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="3">
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="end"
android:text="#string/aminus" />
<com.google.android.material.slider.Slider
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_weight="0.5"
android:gravity="end"
android:text="#string/aplus" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
The cause of the issue is Slider. I'm trying to solve it too but still unsuccessful.
Sorry for late reply... Use AppCompatSlider or simply replace it by the traditional Seekbar. I also faced the same issue with material slider.

Android XML error while generating signed .apk file

I've not opened this particular project for about 3 months but when I tried to generate a signed .apk file, I get this one error only:
C:\app\src\main\res\layout\fragment_newanswers.xml:57: Error: The id "linearLayout2" is not defined anywhere. [UnknownId]
android:layout_alignTop="#+id/linearLayout2"
Here's my current code in that xml file:
<TextView
android:text="OptionView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtOptionTitle"
android:textSize="24sp"
android:textAlignment="center" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txtOptionTitle"
android:layout_alignParentStart="false"
android:layout_alignParentBottom="false">
<!--
<TextView
android:text="QuestionView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtQuestionTitle"
android:textAlignment="center"
android:textSize="18sp" />
-->
<com.rokonoid.widget.ExpandableTextView
android:id="#+id/txtQuestionTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.bozapro.circularsliderrange.CircularSliderRange
android:id="#+id/cirAns"
android:layout_width="wrap_content"
android:layout_height="343dp"
circular:start_angle="270"
circular:end_angle="300"
circular:start_thumb_size="0dp"
android:paddingLeft="75dp"
android:paddingRight="75dp" />
<TextView
android:text="5%"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/linearLayout2"
android:layout_centerHorizontal="true"
android:id="#+id/txtPercent"
android:textAlignment="center"
android:textSize="36sp"
android:layout_marginTop="150dp" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:text="Back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnQnsBack"
android:layout_weight="1" />
<Button
android:text="Next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnQnsNext"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Funny thing is, it worked multiple times previously and I did not make any changes at all. I can also rebuild and clean build it without errors. Oddly, my backup versions which are Identical, generate this ONE same error for my 6 different xml files here:
Error:(5) Error: Suspicious namespace and prefix combination [NamespaceTypo]
It points to this line in each of the 6 files:
xmlns:app="http://schemas.android.com/tools"
My guess is I'm not calling something in the MainActivity (but that would not explain why it has always worked -with fully functioning .apk) Any thoughts?
Thanks heaps!
James
Remove this line
android:layout_alignTop="#+id/linearLayout2"
From
<TextView
android:text="5%"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/linearLayout2"
android:layout_centerHorizontal="true"
android:id="#+id/txtPercent"
android:textAlignment="center"
android:textSize="36sp"
android:layout_marginTop="150dp" />
As i see no layout with id linearLayout2 in your file above. Errors of such kind are not generated in the debug build but in the realease build.
As #Malik Ahhsan said, just remove the android:layout_alignTop="#+id/linearLayout2"

updating design and support libs broke UI

currently we are using design and support libs 23.1.1 , when i updated to 25 there is a big gap in the layout and i can't figure out why
unfortunately i need more reputation to post links , all the links inside the file , sorry.
https://gist.github.com/xxqxpxx/a652a0c26a132913cd67faf21a670515
included files : build.gradle , layoutfile.xml , fragmentfile.xml , mainactivity ,activity1.
screenshot before :
screenshot after :
In your layout file change the root Linear layout height form match_parent to wrap_content
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/authors_and_publishers_simpleDraweeView_margin_left"
android:orientation="vertical">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/authors_and_publishers_simpleDraweeView"
android:layout_width="#dimen/author_publishers_simpledraweeview"
android:layout_height="#dimen/author_publishers_simpledraweeview"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/authors_publishers_name_layout_margin_top"
android:orientation="vertical">
<com.kotobi.widget.fonts.views.textviews.RobotoLight
android:id="#+id/authorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:lines="1"
android:text="Name"
android:textSize="#dimen/author_publisher_pop_up_followrs_text_size" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/authors_and_publishers_simpleDraweeView_margin_top">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="#dimen/author_publisher_pop_up_image_dimen"
android:layout_height="#dimen/author_publisher_pop_up_image_dimen"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/author_publisher_pop_up_image_dimen_margin_right"
android:background="#drawable/followers" />
<com.kotobi.widget.fonts.views.textviews.RobotoLight
android:id="#+id/numberOfFollowers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="12"
android:textColor="#color/grey"
android:textSize="#dimen/author_publisher_pop_up_followrs_number_books" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<ImageView
android:layout_width="#dimen/author_publisher_pop_up_image_dimen"
android:layout_height="#dimen/author_publisher_pop_up_image_dimen"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/author_publisher_pop_up_image_dimen_margin_right"
android:background="#drawable/number_books" />
<com.kotobi.widget.fonts.views.textviews.RobotoLight
android:id="#+id/numberOfBooks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="12"
android:textColor="#color/grey"
android:textSize="#dimen/author_publisher_pop_up_followrs_number_books" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>

class file for android.support.v4.widget.TintableCompoundButton not found

I want to Create a CheckBox, My compile
sdk version is 23,
Target version is 23,
build tool version is 23.0.0,
in gradle I'hv added
compile 'com.android.support:support-v4:23.2.0',
compile 'com.android.support:appcompat-v7:23.2.0'
both and in menifest given the app theme as android:theme="#style/Theme.AppCompat.Light.NoActionBar" and no specific theme to Activity. when I run my code its throwing
InflateException line number #23 at xml file, problem while inflating kind of
Then I decided to convery a simple ChcekBox to android.support.v7.widget.AppCompatCheckBox but on the xml file Preview its showing Rendering Problems The following classes could not be instantiated:
- android.support.v7.widget.AppCompatCheckBox
Exception Details java.lang.ClassNotFoundException: android.support.v4.widget.TintableCompoundButton
and if i try to run it it gives me class file for android.support.v4.widget.TintableCompoundButton not found.
So, Any one faced this issue?
<?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:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/lnv_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rlv_header"
android:orientation="vertical">
<android.support.v7.widget.AppCompatCheckBox
android:id="#+id/confirmCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:checked="false"
android:gravity="start"
android:text="#string/personal_confirm_text"
android:textColor="#color/black"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/rlv_next"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="40dp"
android:background="#color/crabfx_light_gray"
android:visibility="gone">
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentTop="true"
android:background="#color/crabfx_green" />
<TextView
android:id="#+id/tv_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:drawablePadding="10dp"
android:drawableRight="#drawable/discloser"
android:gravity="center_vertical"
android:text="#string/lbl_next"
android:textColor="#color/black"
android:textSize="18sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="#color/crabfx_green" />
</RelativeLayout>
</RelativeLayout>
and below is the theme to Application tag in menifest
android:theme="#style/Theme.AppCompat.Light.NoActionBar"

Horizontal ListView with parchment library error

I m just trying to use parchment library to add an horizontal listView but it doesn't work for me.
I followed all the instructions to add parchment as an Android library in Eclipse and it's ok for this step. The problem is that when i'm trying to add my horizontal listView in xml file Eclipse shows the error : " Error: String types not allowed (at 'orientation' with value 'horizontal ')"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:layout_width="wrap_content"
android:layout_height="60dp"
android:background="#ff5a5bff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List App"
android:textColor="#fff"
android:textSize="25sp"
android:gravity="center_vertical"
android:layout_centerInParent="true"/>
</RelativeLayout>
<mobi.parchment.widget.adapterview.listview.ListView
xmlns:parchment="http://schemas.android.com/apk/res/res-auto"
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="200dp"
android:clipToPadding="true"
android:drawSelectorOnTop="false"
parchment:orientation="horizontal"
parchment:snapPosition="start"/>
</LinearLayout>
Can you please help
Thank's a lot
Add the following to your root tag,
xmlns:parchment="http://schemas.android.com/apk/res-auto
Also your LinearLayout.TextView 60 dp centered(vertical text)may be simplified
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:parchment="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:text="List App"
android:background="#ff5a5bff"
android:textColor="#fff"
android:textSize="25sp"
android:gravity="center_vertical" />
in documentation xmlns is:
xmlns:parchment="http://schemas.android.com/apk/res/<YOUR PACKAGE NAME>"
and in your code is a:
xmlns:parchment="http://schemas.android.com/apk/res/res-auto"
Please check this

Categories

Resources