I am trying to implement a swiperefreshlayout using the following code in my fragment,
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/recentList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey" >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
Whens tarring the activity i get the error "Error inflating class android.support.v4.widget.SwipeRfreshLayout"
I have never used this control before though i am currently using other controls from v4 support library without issue.
Related
My Flutter app uses Google Pay as a payment method. Following these guidelines, they provide XML buttons (which I have never dealt with).
How can I add one of these button to a flutter widget using dart?
There are different implementations for laying out content for Android versus Flutter.
The layout/googlepay_button.xml layout effectively describes the way the button appears, and drawable/googlepay_button_content.xml contains VectorDrawable file for the Google Pay button. flutter_svg should help you render the contents of the image.
To get this to work with Flutter, you would need to reproduce the xml layout as a Flutter widget tree.
Sample layout black/res/layout/googlepay_button.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="48sp"
android:background="#drawable/googlepay_button_no_shadow_background"
android:paddingTop="2sp"
android:contentDescription="#string/googlepay_button_content_description">
<LinearLayout
android:duplicateParentState="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:duplicateParentState="true"
android:src="#drawable/googlepay_button_content"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:duplicateParentState="true"
android:src="#drawable/googlepay_button_overlay"/>
</RelativeLayout>
It looks like SVG. Try to open all these XML files like SVG, and add it to assets folder in your project.
I want to drag and drop elements into the Design View but I just can't. I can't even see the attributes aside when click into the screen or the default TextView that says 'Hello World!'. I tried restarting Android Studio, rebuild the project, and I still have the problem.
The code below is from my file 'activity_main.xml'.
How did happened?
I just tried to add a 'GridLayout' into the screen design, but to use it I had to install a library to use that grid layout and since I did that, I can't use the design view anymore.
Even I get an 'IDE Fatal Error' (screenshot below).
error ide image:
<?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=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Remove
implementation 'com.android.support.constraint:constraint-layout:+'
from your build.gradle (app)
Hopefully Solve this problem
But the same activity blows up loading on a zebra m6000. Let me state that I am a novice using Android Studio and Java. I have been a VB programmer for many years.
The XML has 2 includes. One foe each vertical linear layout. I can add the XML's for them if needed.
What could cause the rendering to work on one android device (which is running an earlier version of OS ) but fail on newer device.
Here is 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:background="#color/colorBackgroundGray"
tools:context="com.procatdt.stockright.activities.PutAwayAreaActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<include
android:id="#+id/include2"
layout="#layout/frm1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="left" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:orientation="vertical">
<include
android:id="#+id/include"
layout="#layout/layout_numpad5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="220dp"
android:layout_weight="1"
android:layout_gravity="right"
/>
</LinearLayout>
</RelativeLayout>
Here is how it is rendering on MC67
Found Issue. One of the Buttons in my include was the culprit. KitKat didn't care but lollipop didn't like the backgroundtint value.
Looking through logcat I saw culprit was a button and from there it was process of elimination.
I'm trying to get a fragment to appear, as rendered in android studio on my phone. I have a Samsung S7 which has 1440 x 2560 pixels, so I've selected the Nexus 6 rendering option in Android Studio.
I have setup my fragment so that it is contained in a content file called content_add_edit_recipe.xml. My activity, activity_add_edit_recipe.xml includes this file, shown below.
<FrameLayout 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/fragment"
android:orientation="vertical"
android:name="com.jcg.grocerylistconverter.AddEditRecipeActivityFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:layout="#layout/fragment_add_edit_recipe"/>
<?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"
tools:context="com.jcg.grocerylistconverter.AddEditRecipeActivity">
here is activity file:
<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_add_edit_recipe"/>
here is the fragment xml for the layout tag (I don't think the rest is relevant right now):
<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:id="#+id/content_add_edit_recipe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical"
tools:context="com.jcg.grocerylistconverter.AddEditRecipeActivityFragment"
tools:showIn="#layout/activity_add_edit_recipe">....
And here is how the fragment looks in the preview:
while here is how it appears on the phone:
I suspect that this is to do with my actual java code in starting the fragment, but I can't figure out for the life of me where/how this is occurring, after tracing through my code the xmls that are inflated.
If nothing is evident from the xmls I will post the code initiating the activity/fragment, but first can someone please point out if something appears off with my xml?
I think you didn't consider text size and length of text inside while designing layout. You should test your layout with different text length and size inside spinner
I have coded a Google Maps application in Xamarin, and am getting this error:
Android.Views.InflateException: Binary XML file line #1: Error
inflating class fragment
I am getting this error when the following line of code is run:
SetContentView(Resource.Layout.MapWithOverlayLayout);
Here is my MapWithOverlayLayout.axml layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment class="SimpleMapDemo.MapWithMarkersActivity"
android:id="#+id/mapWithOverlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
The namespace is called: SimpleMapDemo
Here is my class declaration:
public class MapWithMarkersActivity : Android.Support.V4.App.FragmentActivity
I am using a SupportMapFragment object to display a Google Map
Can I please have some help to get this code working?
I think the problem is with the class attribute you set on the fragment element. Have you tired inflating the layout without it?
I have figured it out myself. I did not have the correct class name.
Here is the correct layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
I had the same problem and fixed it by deleting the AndroidManifest in the obj/Debug/android directory, in the VS or XS and rewriting it so that it only works on me
That is because the app can't distinguish between google play services manifest and the app's one.