relativelayout

Find the position of a bitmap in android imageview when container view scaled centerInside

怎甘沉沦 提交于 2019-12-05 16:22:04
I have an RelativeLayout that contains a custom ImageView, the scaleType="centerInside", I load in a bitmap (usually smaller than the imageView). How can I get the top/left position of where the bitmap was drawn? I need to be able addView's on top a positions relative to the bitmap. RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.scroll_scaled, container, false); ContentImageView image = (ContentImageView) view.findViewById(R.id.base_page); Bitmap bm = mInterfaceActivity.getPageImage(mPageNumber); image.setImageBitmap(bm);` The layout file scrolled_scaled <?xml version="1.0"

Align Button to the bottom of screen

笑着哭i 提交于 2019-12-05 11:48:21
I have two buttons in a frame layout and want them to align at the bottom of screen one below the another. Using android:layout_gravity="bottom" makes them overlap over each other. I have no issues doing it with Relativelayout but relativelayout doesn't supports android:layout_gravity="bottom" My XML Layout file <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg" android:orientation="vertical" > <Button android:layout_width="fill

How to put Imageview Behind other layout

与世无争的帅哥 提交于 2019-12-05 07:52:11
I am using a imageview for animation so that it will look like movement left to right. but my image is displaying front of other views so that user is able to click on image. i am trying to display it behind the other view. <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/layout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/main_bg2" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" >

android - overlap images (playing cards)

喜欢而已 提交于 2019-12-05 07:49:55
I am trying to make the playing cards in my game overlap such that only the first half of a card is seen and the other half is covered by the next playing card. The only card that should be completely visible will be the last/rightmost card. I have used the following code with both framelayout and relativelayout to no avail. can anyone offer some suggestions? public int shouldShow(int numberOfCards, int card, int id) { if(card == -1) hide(id); else { findViewById(id).setBackgroundDrawable(deckimages[card]); //findViewById(id).offsetLeftAndRight(findViewById(id).getWidth()* numberOfCards / 2);

动态加载布局和控件的方式实现动态加载(用listView解决EditText问题挺麻烦)

怎甘沉沦 提交于 2019-12-05 05:06:11
//第一步要声明些map来保存这些控件 Map<String, EditText> map_edit ; // 根据 mxb中的 autobh ->memo封装 控件 Map<String, String> map_v ;// 封装mxb中的autobh->jcjg List<String> list_bh ; // 封装mxb中 autobh Map<String, String> map_jcnr = new HashMap<String, String>(); // 封装mxb中的autobh->jcnr:为发现问题设置 //第二步 刚进来的时候,先需要获取一些基本数据,比如这里获得一个对象数组 cyjxdList=czff.GetList_Person(MainActivity.this,zfrybh, mima, bsh); 第三步,根据获取到的数据,要填入相应的内容了,并且获取索输入的内容,addview在handleMessage(Message msg)中可以调用, /*生成视图1*/ @SuppressLint("NewApi") private void addview() { // TODO Auto-generated method stub list_bh = new ArrayList<String>(); for(int i=0;i<size;i++)

Adding image programmatically to RelativeLayout

浪子不回头ぞ 提交于 2019-12-05 02:44:36
问题 I want to add to a linearlayout, various relative layouts via code. Each relative layouts consists of: an imageview at the left, a textview beside it to the right (exactly in the middle) and another Image at the right. I must add them using data read from a database. It must be with relativelayout because I want to use a listener over the image and a different listener over the RL. Each relativelayout looks like this thing I have in XML. <RelativeLayout android:id="@+id/relativecanal" android

Maximize visible rows in a listview

浪尽此生 提交于 2019-12-04 19:09:05
Here's my code for items in a list.. Suppose I'm inflating this TextView into the ListView <TextView android:id="@+id/textviewItemList" android:layout_width="fill_parent" android:layout_height="50dp" android:paddingBottom="10dip" android:paddingLeft="10dip" android:paddingTop="10dip" android:textSize="35px" /> And here is my code for ListView , inside a RelativeLayout having only 3 rows are visible with others as scrollable. RelativeLayout having height of x3 of the height of text view... <RelativeLayout android:layout_width="wrap_content" android:layout_height="150dp" android:layout_marginTop

Using layoutparams in relativeLayout with dp

不羁的心 提交于 2019-12-04 16:44:35
I m making an app and i want to be able to move a view using its margins dynamically. I tried using this : RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)cover.getLayoutParams(); params.leftMargin= 470; params.topMargin= 20; cover.setLayoutParams(params); (cover is an ImageView) The problem with this code its that it uses px instead of dp. I also tried using DisplayMetrics to convert my px values to dp but failed . Can you help me ? You need to set margin according to dpi - DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager)

Android layout issues

随声附和 提交于 2019-12-04 15:10:44
I can't for the life of me figure this out. I am attempting to have the following layout (vertically): ImageView (filling all available space) TextView (taking vertical space as needed) EditText (taking vertical space as needed) Button Button Button (spaced equally) I have the following layout setup. The image view is currently set at 200dip. What should this value be to fill all available space? The other components should come first and the image view should get what's left over. I have searched for an example on this and have not found anything yet. <RelativeLayout xmlns:android="http:/

Android — Hiding Views

∥☆過路亽.° 提交于 2019-12-04 14:32:12
Okay, so I've done some looking around and I see how you are SUPPOSED to do it, but for me, it is just not working. I need to be able to set the alpha of a RelativeLayout both in XML and in code. For my XML, I have the following <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/player_controls" android:layout_height="match_parent" android:layout_width="match_parent" android:alpha="0.0"> <RelativeLayout android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/player_controls_touch