i got a problem with setContentView which throws me a null pointer.
In my mainFrame i got a small SurfaceView which takes about 50% of the screen.
I wanted to implement a method which makes that SurfaceView go Full Screen if you long clicked it. I did it like this:
final FrameLayout frame = (FrameLayout) findViewById(R.id.frame_layout);
frame.setOnLongClickListener(new OnLongClickListener() {
boolean clicked = false;
#Override
public boolean onLongClick(View v) {
if (clicked){
clicked = false;
(MyActivity.this).setContentView(R.layout.main);
} else {
clicked = true;
(MyActivity.this).setContentView(R.layout.fullScreen);
}
return true;
}
});
Can someone help me how to fix this problem?
Greetings
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
android:orientation="vertical"
android:weightSum="1"
android:background="#drawable/background_new" >
<TextView
android:text="#string/measures"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/text_measures"
android:textColor="#ff444444"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
/>
<ImageButton
android:contentDescription="#string/desc_edge"
android:layout_toRightOf="#id/text_measures"
android:id="#+id/edges_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/edges_black"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="30dp"
android:onClick="edge_handler"
android:background="#null"
/>
<FrameLayout
android:background="#xml/border"
android:id="#+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginBottom="35dp"
android:layout_marginRight="200dp"
android:layout_marginTop="80dp"
android:layout_below="#id/text_measures"
>
</RelativeLayout>
I know it looks like a FrameLayout but dont get fooled it was done by someone else and it is actually a SurfaceView.
Just change the layout parameters of the SurfaceView onLong click of frame. No need to setContentView again.
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
surfaceView.setLayoutParams(lp);
Related
I have an OnClickListener that listens to Button A clicks. I also have 2 TextViews below the Button.
I want that on every click on Button A, the 2 TextViews will switch their places between them, like this:
Before clicking:
TextView A
TextView B
After clicking:
TextView B
TextView A
How can I do it? Is there a special function that meant to do that? or some kind of a trick? Thanks!
actvity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="start"
tools:context="com.intap.tof.MainActivity">
<TextView
android:id="#+id/txtA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp"
android:visibility="visible"/>
<TextView
android:id="#+id/txtB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtA
android:layout_marginTop="83dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="visible"
android:textSize="20dp" />
</RelativeLayout>
MainActivity.java:
txtA = (TextView) findViewById(R.id.txtA);
txtB = (TextView) findViewById(R.id.txtB);
float mAX = txtA.getX();
float mAY = txtA.getY();
float mBX = txtB.getX();
float mBY= txtB.getY();
txtA.setX(mBX);
txtA.setY(mBY);
txtB.setX(mAX);
txtB.setY(mAY);
Trick is changing the x and y axis of both views :
Your xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="start"
tools:context="com.intap.tof.MainActivity">
<TextView
android:id="#+id/txtA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp"
android:text="A"
android:tag="A"
android:clickable="true"
android:visibility="visible"/>
<TextView
android:id="#+id/txtB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtA"
android:text="B"
android:tag="B"
android:clickable="true"
android:layout_marginTop="83dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="visible"
android:textSize="20dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="switch"
android:id="#+id/btn1"
android:onClick="onClickButton"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Java Code :
public class MainActivity extends Activity {
TextView txtA,txtB;
boolean _isOnTxtA;
Button btn1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtA = (TextView)findViewById(R.id.txtA);
txtB = (TextView)findViewById(R.id.txtB);
btn1 = (Button)findViewById(R.id.btn1);
}
public void onClickButton(View v)
{
float mPos1x,mPos1y,mPos2x,mPos2y;
mPos1x = txtB.getX();
mPos1y = txtB.getY();
mPos2x = txtA.getX();
mPos2y= txtA.getY();
if(_isOnTxtA)
{
txtB.setX(mPos2x);
txtB.setY(mPos2y);
txtA.setX(mPos1x);
txtA.setY(mPos1y);
_isOnTxtA = false;
}
else
{
txtB.setX(mPos2x);
txtB.setY(mPos2y);
txtA.setX(mPos1x);
txtA.setY(mPos1y);
_isOnTxtA= true;
}
}
}
View.bringToFront method may be useful.
Where your layout is like:
<LinearLayout>
<TextView A>
<TextView B>
</LinearLayout>
To call bringToFront on TextView A will bring it front (the last position in the parent LinearLayout).
<LinearLayout>
<TextView B>
<TextView A>
</LinearLayout>
For more detailed example, below is layout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/text_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="#+id/text_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text_a" />
<TextView
android:id="#+id/text_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text_b" />
</LinearLayout>
In your OnClickListener (in your Activity) call:
View textViewA = findViewById(R.id.text_a);
textViewA.bringToFront();
This should work.
Toggling behavior can be achieved by this application. For example:
ViewGroup textHolder = (ViewGroup) findViewById(R.id.text_holder);
textHolder.getChildAt(0).bringToFront();
ViewGroup.getChildAt(0) always returns the first child of the ViewGroup. So everytime you call bringToFront on the first child will be bring to front.
All previous answers do not work because you use a relative layout where a linear layout will suffice.
If you have to go RelativeLayout, do the following in your click listener
TextView textA = (TextView) findViewById(R.id.txtA);
TextView textB = (TextView) findViewById(R.id.txtB);
RelativeLayout.LayoutParams textALayoutParams = (RelativeLayout.LayoutParams) textA.getLayoutParams();
textALayoutParams.addRule(RelativeLayout.BELOW, R.id.txtB);
textA.setLayoutParams(textALayoutParams);
RelativeLayout.LayoutParams textBLayoutParams = (RelativeLayout.LayoutParams) textB.getLayoutParams();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
textBLayoutParams.removeRule(RelativeLayout.BELOW);
} else {
textBLayoutParams.addRule(RelativeLayout.BELOW,0);
}
textB.setLayoutParams(textBLayoutParams);
This will place A under B. You can do the same for reversing.
I'm having an issue with button click events and seekbar events not firing. When I drag on my seekbar, the slider changes position visually but there's no event being fired in my OnSeekBarChangedListener. I also have an ImageButton that should receive click events but it does not fire either. The MyView at the bottom here handles touch events properly. It holds a GLSurfaceView that I can pan around and pinch-zoom on. What could be causing the events to not fire?
Here's my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tec_root">
<ImageButton
android:id="#+id/button_star"
android:contentDescription="#string/star_description"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#drawable/star_empty"
android:background="#00000000"
android:scaleType="fitXY"/>
<LinearLayout
android:id="#+id/view_plot"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#id/button_star"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/button_star"
android:layout_toStartOf="#id/button_star"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:progress="50"
android:layout_alignBaseline="#id/button_star"
android:id="#+id/seekbar" />
</RelativeLayout>
And here are the listeners:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_activity);
prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
starred = prefs.getBoolean("starred", false);
final ImageButton starButton = (ImageButton) findViewById(R.id.button_star);
starButton.setImageDrawable(ContextCompat.getDrawable(this, (starred ? R.drawable.star_filled :
R.drawable.star_empty)));
starButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
starred = !starred;
prefsEditor = prefs.edit();
prefsEditor.putBoolean("starred", starred);
prefsEditor.apply();
starButton.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(),
(starred ? R.drawable.star_filled : R.drawable.star_empty)));
}
});
((SeekBar) findViewById(R.id.seekbar)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
Log.e("TEST", "Seekbar onProgressChanged called");
Toast.makeText(getApplicationContext(), "Seekbar fired", Toast.LENGTH_SHORT).show();
// respond to update
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
MyView myView = new MyView(this, points, false);
((LinearLayout) findViewById(R.id.view_plot)).addView(myView);
}
try this, replace LinearLayout with FrameLayout, it's not best at perfomance but works well
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tec_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<SeekBar
android:id="#+id/seekbar"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:background="#ABABAB"
android:layout_weight="1"
android:progress="50" />
<ImageButton
android:id="#+id/button_star"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#00000000"
android:contentDescription="#string/star_description"
android:scaleType="fitXY"
android:src="#drawable/star_empty" />
</LinearLayout>
<FrameLayout
android:id="#+id/view_plot"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
/>
</LinearLayout>
Try changing your code to this:
MyView myView = new MyView(this, points, false);
myView.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
((LinearLayout) findViewById(R.id.view_plot)).addView(myView);
Could this be reproduced by removing the GLSurfaceView?
If so, changing SurfaceView.setZOrderOnTop might help.
http://developer.android.com/reference/android/view/SurfaceView.html#setZOrderOnTop(boolean)
there may be issue of layout design so please rearrange the components of ui.
seekbar is over imagebutton so android platform is not able to detect touch event.
set layout_below in seekbar
One possible reason for this could be touch handling in custom MyView. We have to be very careful about return value of onTouchEvent() function. Try returning "true" from your onTouchEvent() if you are consuming event else return "false".
I am using view switcher in my project.
In my xml I have created 2 layouts with all same Id's.
After I switch my view I can not switch to previous view because I am using same ID's in both layouts.
Now how can I use one listener in java code for both layouts in view switcher.
I dont want to create an another id and create another listener to switch again.
My xml is as below.
<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/profileSwitcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="#string/hello_world" />
<Button
android:id="#+id/switchBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Switch" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="#string/hello_world" />
<Button
android:id="#+id/switchBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Switch" />
</RelativeLayout>
</ViewSwitcher>
My java code is as follows
final ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.profileSwitcher);
Button btn = (Button) findViewById(R.id.switchBtn);
btn.setOnClickListener(new OnClickListener() {
private boolean switchCheck;
public void onClick(View v) {
new AnimationUtils();
switcher.setAnimation(AnimationUtils.makeInAnimation(getApplicationContext(), true));
if (!switchCheck) {
switcher.showNext();
switchCheck = true;
} else {
switcher.showPrevious();
switchCheck = false;
}
}
});
Please help..
Crete different ids for parent relative layout in xml.
And then in java file check which relative layout button is used.
using method
step 1)
RelativeLayout r1 = RelativeLayout findviewbyId(R.id.rl1)
RelativeLayout r2 = RelativeLayout findviewbyId(R.id.rl2)
step2)
if button.getParent equals to R1 then ...
else .....
Just try to change ur text in any of the button or textView .may be ur view is switching but because the code for both the layouts is exactly same u r not able to differentiate.
I am a new android developer and I am trying to create an android app for android in which menu items will be displayed along with description cost and image.
I have implemented List activity to display the items in a list. I made an image Button which will show the image in a thumbnail. I want to be able to view a high resolution image of the thumbnail when I tap on the image button. I have implemented an onClickListener to listen to the tap event but I do not know the methods that will make the image zoom out on tap.
I have followed this link
but it is quite ambiguous to understand. The Animator class doesn't exist. Can someone guide me out o fthis?
I found the solution after searching for almost a week.
I used PopupWindow Class for the purpose
Following is the Java Code.
PopupWin.java
public class PopupWin extends Activity{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button bPopup = (Button)findViewById(R.id.openpopup);
bPopup.setOnClickListener(new Button.OnClickListener(){
#Override
public void onClick(View arg0) {
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
Button bDismiss = (Button)popupView.findViewById(R.id.dismiss);
bDismiss.setOnClickListener(new Button.OnClickListener(){
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
popupWindow.dismiss();
}});
popupWindow.showAsDropDown(bPopup, 50, -30);
}});
}
}
popup.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pop"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/dim_back" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/dim_back"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:orientation="vertical"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:src="#drawable/appetimg01" />
<Button
android:id="#+id/dismiss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20sp"
android:text="Go Back"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/appetizerDes1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="0.40"
android:text="Tap the Image to view High Resolution Image."/>
<Button
android:id="#+id/openpopup"
android:layout_width="80sp"
android:layout_height="80sp"
android:layout_gravity="right"
android:layout_margin="40sp"
android:background="#drawable/custombutton"
android:scaleType="centerCrop" />
</LinearLayout>
</LinearLayout>
The background was appearing white but I wanted it transparent for which I created back_dim.xml in drawables and set it along with android:background="#drawable/back_dim".
I've created a somewhat simple layout with a total of 4 buttons: 3 buttons at the bottom of the layout are side by side (in a RelativeLayout) and on huge button almost in the middle of the screen.
On Ice Cream Sandwich and Jellybean, I can click any of the buttons and everything works fine (i.e.The respective onClick functions are called) but weirdly enough on Gingerbread any of the 3 buttons at the bottom work but not the one in the middle. onClick fires off many instructions, none of which are being executed so as far as I can tell, it's not being called and I don't know why.
Code for layout is given below. Any help is greatly appreciated!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/main_off"
android:orientation="vertical"
android:weightSum="10" >
<ImageButton
android:id="#+id/button_activate"
android:layout_width="155dp"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="170dp"
android:layout_weight="7.2"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="activate"
android:src="#drawable/transparent" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginTop="80dp"
android:layout_weight="2" >
<ImageButton
android:id="#+id/button_help"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="openhelp"
android:src="#drawable/transparent" />
<ImageButton
android:id="#+id/button_settings"
android:layout_width="55dp"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginTop="0dp"
android:layout_toLeftOf="#+id/button_help"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="opensettings"
android:src="#drawable/transparent" />
<ImageButton
android:id="#+id/button_contact"
android:layout_width="70dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_marginTop="0dp"
android:layout_toRightOf="#+id/button_help"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="opencontact"
android:src="#drawable/transparent" />
</RelativeLayout>
</LinearLayout>
Activity that calls the layout (main.xml):
//bunch of imports
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);
boolean serviceOn = isMyServiceRunning();
if(serviceOn==true) layout.setBackgroundResource(R.drawable.main_on);
else if (serviceOn==false) layout.setBackgroundResource(R.drawable.main_off);
}
#Override
protected void onResume() {
super.onResume();
LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);
boolean serviceIsOn = isMyServiceRunning();
if(serviceIsOn==true) layout.setBackgroundResource(R.drawable.main_on);
else if (serviceIsOn==false) layout.setBackgroundResource(R.drawable.main_off);
}
public void activate(View v){
LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);
Resources res = getResources();
Drawable on = res.getDrawable(R.drawable.main_on);
Drawable off = res.getDrawable(R.drawable.main_off);
if (layout.getBackground().getConstantState() == off.getConstantState()){
layout.setBackgroundResource(R.drawable.main_on);
Toast.makeText(getApplicationContext(), "App has been activated", Toast.LENGTH_SHORT).show();
turnon();
}
else if (layout.getBackground().getConstantState() == on.getConstantState()){
layout.setBackgroundResource(R.drawable.main_off);
Toast.makeText(getApplicationContext(), "App has been deactivated", Toast.LENGTH_SHORT).show();
turnoff();
}
}
}
I can run this fine on my emulator for both 2.2 and 2.3.
The only thing I can suggest is to try to remove drawables (maybe some settings there are screwing things up), or try to make your relative layout height 0dp, since you are using weight_sum