relativelayout

Adding multiple buttons on the fly

独自空忆成欢 提交于 2019-12-24 01:45:51
问题 I want to add multiple buttons dynamically through the code on button click, I searched many previous posts which shows to add single button, but I need multiple ones. Attached is the sample code. public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button b1 = (Button)findViewById(R.id.button1); b1.setOnClickListener(new View.OnClickListener() { @Override public

Adding Text views in multiple rows in Relative layout programmatically

[亡魂溺海] 提交于 2019-12-24 00:55:58
问题 I'm trying to achieve the following view in image programmatically. I am adding text view to relative layout dynamically. My problem is text view are added as required to right of each text view added prior. But after one row completion other text views are hidden due to the size of screen. How to add other remaining text view to next line after they added in one line. Whether my approach is wrong to achieve this. Please guide me. Thanks. Here is code : RelativeLayout llTags = (RelativeLayout

Android ScrollView with RelativeLayout

风流意气都作罢 提交于 2019-12-24 00:50:12
问题 I have a fragment with two RelativeLayout, one inside the other. This fragment is inside a tab. I want that the internal layout(layoutInternal) is scrollable, but with the following code does not work. I create the view object into the layoutInternal dinamically. Where is my mistake? <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layoutExsternal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >

onConfigurationChanged() is not being called on orientation change

*爱你&永不变心* 提交于 2019-12-24 00:43:36
问题 I saw some related questions on SO, but I'm not able to resolve my issue. I've created separate layout for PORTRAIT and LANDSCAPE mode. I've modified the AndroidManifest.xml file for corresponding orientation change but onConfigurationChanged() is not working when I'm implementing it in activity. Now the issue is at layout.addView(graphView, lp); in onCreate() . I've written absolute hard-coded value in GraphView class. So it works perfectly foe PORTRAIT mode but graphView is not correctly

how to get the bottom of a layout in android?

南楼画角 提交于 2019-12-24 00:05:39
问题 I'm using a relative layout in Android, and when adding a view to the bottom of the screen the view is placed lower than the actual bottom of the screen, where the user cant actualy see it. view.setY(container.getBottom()-view.getHeight()); container.addView(view); container is a RelativeLayout. i have also tried to use container.getHeight() which gave me the same result, and all the other solutions i found where using the xml file, which doesnt work for me since i need to add the view

How to adjust relative layout when zooming an item?

喜你入骨 提交于 2019-12-23 23:06:44
问题 I have created a screen in which have created RelativeLayout dynamically. After that I have added some ImageView under RelativeLayout . The requirement is that when I click on any Image View then that ImageView should be zoom by 20% and other images show be adjusted automatically. So I have two problems: How to zoom a particular ImageView (other ImagesView should be zoom out if already zoomed in) How to adjust other Image View when perform zoom in and zoom out Please suggest, I have not

Order of evaluation with relative layouts, best practices and parsing of relative-layout

旧时模样 提交于 2019-12-23 17:22:59
问题 I read this " It used to be that Android would use a single pass to process RelativeLayout-defined rules. That meant you could not reference a widget (e.g., via android:layout_above) until it had been declared in the XML. This made defining some layouts a bit complicated. Starting in Android 1.6, Android uses two passes to process the rules, so you can now safely have forward references to as-yet-undefined widgets. " I do not know what is the problem maybe is eclipse problem, but even I use 2

Can't make a view overlay another view in FrameLayout

无人久伴 提交于 2019-12-23 11:49:11
问题 I want to make my ImageView on top of my Button, but the button will always overlay the ImageView , no matter which layout I choose or the way I arrange my layout... this is an example of a FrameLayout that I tried: EDIT: just for simplifying my question : Why doesn't the FrameLayout work as it should? (you can copy this code to your Android Studio and see yourself) <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout

Programmatically change RelativeLayout toRightOf to toLeftOf

回眸只為那壹抹淺笑 提交于 2019-12-23 08:54:04
问题 i'm making chat app. I want to put timestamp besides the chat bubble. The messages will be aligned left (for received) and right (for sent). So, I'm looking for a way to change toLeftOf to toRightOf . For now, it looks like this: Here's my XML code for each message (I have ArrayAdapter that handle this) <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/wrapper" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android

Android Responsive Image Button Layout

China☆狼群 提交于 2019-12-23 05:27:55
问题 I'm trying to create the design shown below but with a responsive height on the image buttons for different screens. While I can get a responsive width by using android:layout_weight I can't manage to apply the same method to the button's height. What I'm trying to achieve is what's shown below but with the height of the screen evenly distributed amongst the buttons. i.e. 25% of the screen's height for each row of buttons. Any help would be greatly appreciated! <?xml version="1.0" encoding=