Tag: layout

RelativeLayout inside LinearLayout?

I was wondering what I am doing wrong here, why does surrounding these buttons in a RelativeLayout cause an error? I haven’t edited layouts much, can I not just stick in a Relative or Linear layout like that? If I don’t surround the buttons in a layout they appear beneath each other, I am just […]

Setting margin and gravity of textview in code doesn't work

If i set only margin for my textview, that is inside linear layout, everything works. If i set only gravity for my textview, it works. But if i set both attributes (gravity and margins), gravity remains left with margins set successfully. My code for setting both attributes that doesnt work as expected: tv2=new TextView(this); tv2.setText(“Text”); […]

RecyclerView Multiple Layout View(s) in an Adapter class

Here is what I have achieved ? 3 different sections, 10 different items in each section. Here is the tutorial link I am following and below is the Screenshot: Trying to show different Views for each and every Section. Like: For Section 1 (layout_1.xml) For Section 2 (layout_2.xml) For Section 3 (layout_3.xml) But showing layout […]

ListView header ignores layout_height

I inflate this view, and add it to my ListView as a header. I am trying to make it 500dp high (hard coded, for the sake of this example) <?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:background=”@drawable/repeat_background” android:layout_height=”500dp”> <ImageView android:id=”@+id/filter_menu” android:src=”@drawable/ic_sort” android:layout_gravity=”center_vertical” android:padding=”8dp” android:layout_weight=”0″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:onClick=”showPopup”/> </LinearLayout> The ListView does not respect the authoritah […]

How to categorize android layout in to small,medium,large,x-large screen?

I created 4 different layout files and placed it in layout , layout-small,layout-large,layout-xlarge. folder and TESTED IN QVGA,HVGA,AND WXGA EMULATOR. But it is only taking the default layout(which i placed it in layout folder)for all emulator. Any solution?

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.ViewGroup.getPaddingLeft()' on a null object reference

I’m trying to use an Intent to start an Activity, but the mentioned error occurs on second activity’s setContentView(); Here are my code and the layout file. itemactivity.xml: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”match_parent” android:layout_width=”match_parent” android:orientation=”vertical”> </LinearLayout> MainActivity: Intent i=new Intent(MainActivity.this,ItemActivity.class); startActivity(i); ItemActivity: @Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.itemactivity); // this is where error […]

How to make a linear layout add a child view in a new line?

I want to define a layout that it’s orientation is horizontal, but if width of the child views exceeds the width, it adds the new child view in a new line. can it be done?

How To Use Multiple TouchDelegate

i have two ImageButtons, each inside a RelativeLayout and these two RelativeLayouts are in another RelativeLayout, i want to set TouchDelegate for each ImageButton. If normally i add TouchDelegate to each ImageButton and it’s parent RelativeLayout then just one ImageButton works properly, Another one doesn’t extend it’s clicking area. So PLease help me on how […]

how to create three columns in TableLayout

I am developing a screen that uses TableLayout. Here I am easily able to create two columns. but how can I create three columns ?

What is the default height on Androids TabLayout

Seems like something that should be easy to find, but it’s harder than I thought. What is the default height on the TabLayout in DIPs?

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.