Why Do I get rendering issues in Android Studio? - android-studio

<?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.yossikally.hello.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
<!--<android.support.design.widget.FloatingActionButton-->
<!--android:id="#+id/fab"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="bottom|end"-->
<!--android:layout_margin="#dimen/fab_margin"-->
<!--android:src="#android:drawable/ic_dialog_email" />-->
</android.support.design.widget.CoordinatorLayout>
I built the simplest hello world project.
In the xml design pane I get what's in the picture
Tried to change themes and change version. Get the same

please add to your App gradle file Android Design Support Library:
compile 'com.android.support:design:23.+'

Related

I want to add my website menu in web-view in navigation drawer

I converted my website into an Android web-view using an empty activity. The only issue I'm having right now is displaying my website pages in the form of a menu in the navigation drawer. Please assist me in achieving this.
Here is my Layout Activity-main.xml code
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout 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:id="#+id/swipeRefreshLayout"
tools:context="com.developer.arsltech.MemberPortal.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:layout_width="match_parent"
android:layout_height="9dp"
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_marginTop="-2dp"
android:progress="20"
android:visibility="gone"
/>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/myWebView"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:id="#+id/relativeLayout">
<ImageView
android:layout_width="240dp"
android:layout_height="240dp"
android:src="#drawable/no_internet"
android:layout_centerHorizontal="true"
android:id="#+id/noConnectionLogo"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Internet Connection"
android:layout_below="#+id/noConnectionLogo"
android:textAlignment="center"
android:textSize="26sp"
android:id="#+id/txtNoConnection"/>
</RelativeLayout>
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
Please assist me in achieving this.

Button not showing android studio

If i put the button before appbar it does not show up. If i put it inside, it shows up but it does not fit properly (height is under imageview and the two can not be in the same height). I tried different layouts other than coordinatorlayout and it hapens again there too.
<?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"
android:alpha="1"
tools:context=".MainActivity">
<ImageButton
android:id="#+id/search_button"
android:layout_width="55.5dp"
android:layout_height="55.5dp"
android:layout_marginLeft="298.5dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_baseline_search_24" />
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<ImageView
android:id="#+id/title"
android:layout_width="155dp"
android:layout_height="55.5dp"
android:minHeight="?actionBarSize"
android:src="#mipmap/ic_banner_foreground" />
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabGravity="center"
app:tabMode="auto" />
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="59dp"
android:layout_marginTop="672dp"
android:background="#color/colorPrimary"
android:theme="#style/AppTheme.AppBarOverlay">
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="566dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="566dp" />
</androidx.viewpager.widget.ViewPager>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
It is not showing because you've used "#android:color/transparent" as background for your ImageButton. Chose another color and it will be visible. Or just add some text so that you can see it.

Android studio - can't see text in AppTheme

I have just started android studio, and I can't seem to see the "Hello World" text in my build:
When I switch to another theme I am able to see the text, what could be the problem?
Edit:
The color is not the same as the background.
layout 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=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textColor="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.44" />
</android.support.constraint.ConstraintLayout>
Thank you!
According to the information presented about the problem, you need the closing label of ConstraintLayout
</android.support.constraint.ConstraintLayout>
they stay like this
<?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=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textColor="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.44" />
</android.support.constraint.ConstraintLayout>
Or you may need to restart the android studio cache
go to the menu file> restat caches / restart
I hope I've helped

Notification bar showing strange shadow Android Studio

I'm working on a project in Android Studio. I created a Navigation Drawer project, using 16 as my minSdkVersion. My Notification bar has a strange shadow (this is my AppBar) and I want to have material design's notification bar (this is Material Design's Appbar).
Default code is:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" /
</android.support.v4.widget.DrawerLayout>
app_bar_main.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.ingsoft.url.gudbox.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay"
android:background="#android:color/transparent"
android:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" /
</android.support.design.widget.CoordinatorLayout>
I've found similiar questions like this, but they didn't help.
Thanks!

Coordination Layout Don't Work With Tab Layout

Good day can you help me correct this one?
In my activity_main.xml, I used Coordination Layout So that my Appbar will work.
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
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:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.eccp.projects.ecosavers.ecosavers.activities.eco_detailed_information">
<!--COORDINATOR LAYOUT-->
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinator_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#ffffff">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<include
android:id="#+id/toolbar"
layout="#layout/tool_bar"
/>
<android.support.design.widget.TabLayout
android:id="#+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:tabMode="fixed"
app:tabGravity="fill"/>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:background="#ffffff"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
app:headerLayout="#layout/header"
app:menu="#menu/drawer"/>
And In my First Tab my - Organizations feeds don't work, it stuck and will not me allow to slide up to show up the feeds. But sometimes it will work sliding up but, there is an overlapping of layout. I just include my cardview_items.xml as an overview on how it looks like.
<RelativeLayout
android:orientation="vertical"
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:scrollbarAlwaysDrawVerticalTrack="true"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.eccp.projects.ecosavers.ecosavers.activities.eco_detailed_information">
<!--COORDINATOR LAYOUT-->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_marginTop="1dp">
<!--Dummy Value 1-->
<include
android:id="#+id/card_item"
layout="#layout/eco_events_cardview" />
<include
android:id="#+id/card_item"
layout="#layout/eco_events_cardview" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
I really need your help. I'm stuck with this one.
Thank you in advance.
It should be fairly easy to fix:
Remove ViewPager from AppBarLayout
Add ViewPager as a sibling to a AppBarLayout and add for it app:layout_behavior="#string/appbar_scrolling_view_behavior" and set layout_width & layout_height to match_parent
So your layout should look like afterwards:
<android.support.design.widget.CoordinatorLayout
....>
<android.support.design.widget.AppBarLayout
.....>
<include
android:id="#+id/toolbar"
layout="#layout/tool_bar"/>
<android.support.design.widget.TabLayout
.../>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
.....
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
I hope, it helps.

Resources