Tag: android-layout

How to increase the height of table row according to screens?

I would like to know how can I increase the height of table row so it looks proportionate in larger screen sizes. Currently all of the textviews and edittexts(placed in table rows) appear on the left side of the screen instead of occuping the whole screen( only in larger screen sizes). Here is the xml […]

No resource identifier found for attribute 'paddingEnd' in Package 'android'

I have a problem with the XMl file in v17/mr-media_route_list_item.xml. I keep getting this error and have not found a solution yet! Here is a printshot of the XML and the Problems* XML CODE BELOW : <?xml version=”1.0″ encoding=”utf-8″?> <!– Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 […]

Android: how to programmatically set width of ImageView inside TableRow

How do you programmatically set the width of an ImageView inside a TableRow? I do NOT want the cell width to change, only the width of the image inside the cell. Layout: (The ellipsis are there to reduce the code) <TableLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:orientation=”horizontal”> <TableRow android:gravity=”center_vertical”> <Button>…</Button> <ImageView android:id=”@+id/fruit” android:layout_width=”120dp” android:layout_height=”44dp” android:src=”@drawable/apple” android:scaleType=”matrix” ></ImageView> […]

How to let a TextView have multiple lines?

I want to show multiple line via TextView and strings.xml . I want to show first few lines until the middle of the page and other lines to show in full of the page. I want to show first few lines with same size of width page. Left of the page is a picture and […]

How to use relativelayout.setBackgroundDrawable() with a bitmap?

I have a RelativeLayout object and want to dynamically change the background image with a dynamically created Bitmap object (it changes its color dynamically). I saw that when I wanted to update the background image of the RelativeLayout object that I can only choose setBackgroundDrawable() which requires a Drawable object as a parameter. My question […]

Android Resources$NotFoundException

I am a beginner so please bear with me. I am creating an app in which the players enter their names into edit texts. This information is retrieved and sent to a second activity through extras. Whenever I run this, I get a Resources$NotFoundException. I am nut sure if this is from my code or […]

Android: center gridview horizontally

I need to center grid view horizontally in my android layout.xml. I have searched google for quite a while but didnt succeed in finding an answer. I can only change gridview horizontal position by changing strechMode, but then my items are not near one another. that i need is items be one near another (without […]

Custom Dialog size to match Theme.Holo.Light.Dialog

If I have an Activity that has it’s theme set to Theme.Holo.Light.Dialog, it will scale great. It will fill the screen on phones in portrait mode almost entirely but in landscape mode it won’t stretch unreasonably long. For example, in this picture from Google, you can see the dialog not filling the whole screen. It […]

Android – set layout background programmatically

I have noticed that the setBackground method for the RelativeLayout object is targeted for API 16 (Android 4.1) and higher, but my application has the target API 8 and I cannot use it. Is there any alternative solution for this problem (besides marking the class/method with TargetApi(16) or changing the target API in the manifest)? […]

Implementing OnClickListener for dynamically created buttons in Android

I dynamically created buttons through code rather than from XML. The code is as below : dynamicview = (LinearLayout)findViewById(R.id.llayout); LinearLayout.LayoutParams lprams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); for(int i=0;i<nob;i++){ Button btn = new Button(this); btn.setId(i+1); btn.setText(“Button”+(i+1)); btn.setLayoutParams(lprams); dynamicview.addView(btn); } I am not finding a way in which I can implement OnClickListener to each of these buttons […]

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