android-relativelayout

RelativeLayout “Couldn't resolve resource…” Android

随声附和 提交于 2019-12-01 14:36:36
问题 When using the below code, I get an error "Couldn't resolve resource @id/item1" Why is this? id/item1 is added before I use it, so I'm not sure why this is coming up. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/item1" android:layout_width="50dip" android:layout_height="50dip" android:src="

android RelativeLayout, equal spacing?

半世苍凉 提交于 2019-12-01 14:24:36
问题 I'm using Relative Layout to create a calculator screen, and i have a row of buttons labeled 1, 2, and 3. I want them evenly spaced, but i'm not sure how to do this with Relative Layout I'm used to using the android:layout_weight function in LinearLayout, and give each of them a value of android:layout_width="fill_parent", as well as a layout_weight="1" any way to get this to happen on calculator screen (without specifying DP or PX) this is what i have set up at the moment, and they are

How to place a RelativeLayout at the bottom of a RelativeLayout?

依然范特西╮ 提交于 2019-12-01 06:42:28
I have a RelativeLayout , and this Layout has two childs, one is a MapView and the other a RelativeLayout that contains a button. I want it to look like that but my transparent box (a RelativeLayout ) is always displayed at the top of the map. <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <com.google.android.maps.MapView android:id="@+id/mapView"/> <test.project.TransparentPanel android:layout_width="fill_parent" android:layout_width="fill_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click Me

How to place a RelativeLayout at the bottom of a RelativeLayout?

♀尐吖头ヾ 提交于 2019-12-01 05:10:52
问题 I have a RelativeLayout , and this Layout has two childs, one is a MapView and the other a RelativeLayout that contains a button. I want it to look like that but my transparent box (a RelativeLayout ) is always displayed at the top of the map. <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <com.google.android.maps.MapView android:id="@+id/mapView"/> <test.project.TransparentPanel android:layout_width="fill_parent" android:layout_width="fill_parent">

Setting up RelativeLayout in java code

最后都变了- 提交于 2019-12-01 03:58:34
I'm having a hard time getting two text views to appear on top of each other in my java code. Here's the code I'm experimenting with: /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); layout = new RelativeLayout(this); text1 = new TextView(this); text1.setText("1"); text2 = new TextView(this); text2.setText("2"); RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams q = new RelativeLayout

Why do I get white space on top and on the bottom of my ImageView in my RelativeLayout?

一世执手 提交于 2019-12-01 02:30:44
I am using a relativelayout to overlay to images. On all screen sizes so far that I have tested (from 2.7 to 10.1 inch) I always get white space on top of my image. In my IDE I always see that my relativelayout is causing the extra space on top and on the bottom of my image. Why is that? I have set all height attributes to wrap_content and even added the adjustViewBounds attribute. Note: You should know that my image is a lot bigger in size, meaning that there will be some sort of scaling. Thanks for your tips! Here is the code: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android=

OnClickListener doesn't work with clickable attribute

自古美人都是妖i 提交于 2019-11-30 18:08:10
So, my problem is that OnClickListener doesn't work when I set android:clickable="true" into my class. This is MyClass xml code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/background" android:clickable="true"> ... ... </RelativeLayout> MyClass.java: public class MyClass extends RelativeLayout implements OnClickListener { public MyClass(Context context) { super(context); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT

Android: Setting Background Image for RelativeLayout?

此生再无相见时 提交于 2019-11-30 17:29:18
I have downloaded an image at runtime. Now I want to set it as a background for RelativeLayout . Does it possible? Check out the setBackgroundDrawable , or maybe createFromPath in the Drawable class. RelativeLayout rLayout = (RelativeLayout) findViewById (R.id.rLayout); Resources res = getResources(); //resource handle Drawable drawable = res.getDrawable(R.drawable.newImage); //new Image that was added to the res folder rLayout.setBackground(drawable); Melvin Miller Instead use: View lay = (View) findViewById(R.id.rLayout); lay.setBackgroundResource(R.drawable.newImage); This works because R

Long Android TextView pushes other views off-screen

霸气de小男生 提交于 2019-11-30 15:41:42
问题 I've got two TextViews side-by-side. TextView1 has a varying length of text, and TextView2 always says "+#". When TextView1 gets long however, it pushes TextView2 off screen. Any ideas how to fix this? Here's my layout code: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/TextView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android

Marshmallow RelativeLayout behaves strange with alignBaseline

半腔热情 提交于 2019-11-30 12:47:21
On Android 6.0 Marshmallow the positioning of an EditText in relation to an ImageView in a RelativeLayout with the attributes baseline and layout_alignBaseline does not work anymore. The behaviour can even be observed in the layout editor in Android studio. On a real Android Marshmallow device or emulatr the EditText in my case is shift outside the screen and not visible. Do I miss some changes, is it a bug? <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match