How to parse same name tag in Android XML DOM Parsing?

Your getValue() method gets MyResource element, from there, you need to get all Items under MyResource and do getElementValue(). Example code is: public Map getValue(Element item, String str) { NodeList n = item.getElementsByTagName(str); for (int i = 0; i < n.getLength(); i++) { System.out.println(getElementValue(n.item(i))); } //Here store it in list/map and return list/map instead of … Read more

How do you create Preference Activity and Preference Fragment on Android?

I found this post (What to use instead of “addPreferencesFromResource” in a PreferenceActivity?) that help me understand that you have to go through a PreferenceFragment in order to do it. In the following explanation I use your.package. just to show that you have to put the package name. Everybody has its own package so please … Read more

How to combine BottomAppBar + FAB with BottomNavigationView

First Way Try this You can Create a CustomBottomNavigationView Here is the good article for CustomBottomNavigationView How I draw custom shapes in BottomNavigationView SAMPLE CODE import android.content.Context; import android.graphics.*; import android.support.design.widget.BottomNavigationView; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; public class CustomBottomNavigationView extends BottomNavigationView { private Path mPath; private Paint mPaint; /** the CURVE_CIRCLE_RADIUS represent the radius of the … Read more

Custom attributes in styles.xml

I figured it out! The answer is to NOT specify the namespace in the style. <?xml version=”1.0″ encoding=”utf-8″ ?> <resources xmlns:android=”http://schemas.android.com/apk/res/android”> <style name=”CustomStyle”> <item name=”android:layout_width”>wrap_content</item> <item name=”android:layout_height”>wrap_content</item> <item name=”custom_attr”>value</item> <!– tee hee –> </style> </resources>

Vertical line using XML drawable

Instead of a shape, you could try a View: <View android:layout_width=”1dp” android:layout_height=”match_parent” android:background=”#FF0000FF” /> I have only used this for horizontal lines, but I would think it would work for vertical lines as well. Use: <View android:layout_width=”match_parent” android:layout_height=”1dp” android:background=”#FF0000FF” /> for a horizontal line.

Add a background image to shape in XML Android

Use following layerlist: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item> <shape android:shape=”rectangle” android:padding=”10dp”> <corners android:bottomRightRadius=”5dp” android:bottomLeftRadius=”5dp” android:topLeftRadius=”5dp” android:topRightRadius=”5dp”/> </shape> </item> <item android:drawable=”@drawable/image_name_here” /> </layer-list>

Activity Layout: Fragment class: vs android:name attributes

As Activity.onCreateView source says: String fname = attrs.getAttributeValue(null, “class”); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Fragment); if (fname == null) { fname = a.getString(com.android.internal.R.styleable.Fragment_name); } That seemingly means that program looks “class” attribute first. And on fail looks “name” attribute. So as far as it’s true using “class” if more efficient.