Tag: layout

How to remove dialog margins?

I’m trying to create a custom dialog to show a list of values at the bottom of screen. How can I remove the dialog margins? I want this… I have this… Dialog code: Dialog d = new Dialog(this); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setContentView(R.layout.dialog_options); Window window = d.getWindow(); WindowManager.LayoutParams wlp = window.getAttributes(); wlp.width = WindowManager.LayoutParams.MATCH_PARENT; wlp.gravity = Gravity.BOTTOM; window.setAttributes(wlp); […]

Android Layout land not working

I’ve been looking at issues in stackoverflow and I’ve tried everything I’ve seen but the layout-land not work. In my code I have and the method onConfigurationChanged @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } And the manifest file: <activity android:name=”com.sde.PlayerTrack” android:theme=”@style/AppTheme” android:configChanges=”orientation|keyboardHidden|screenSize” > </activity> I tried also to remove in the android manifest entry: […]

Android: Setting the Weight parameter programmatically does the opposite of what i want

i’m having a problem with android. I’m setting the Weight parameter in Java, but it’s doing exactly the oposite of what i want. Here’s the code LinearLayout container = new LinearLayout(context); // some code … container.setWeightSum(1f); View v1 = new View(context); v1.setBackgroundColor(Color.parseColor(“#ff0000”)); LinearLayout.LayoutParams p1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); p1.weight=0.1f; View v2 = new View(context); v2.setBackgroundColor(Color.parseColor(“#000000”)); LinearLayout.LayoutParams […]

Clickable custom view in Notification on Android 2.3 or lower

I created a custom notification layout, which have a clickable button. Works so far fine on Android 3 (API Level 11) or higher, but don’t work on Android 2.3, the ContentIntent from the Notification always overlays my layout and can’t be overriden. I can’t click the view, I always click the Notification and start the […]

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 […]

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