Reputation: 362
I am creating an android app with a customized view and a customized ScrollView
. I am attempting to put the custom view inside of the scroll view. It does not appear to work, as I am just receiving a blank screen.
Dashboard.java
package com.commentblock.fandoms;
import com.commentblock.fandom.R;
import com.commentblock.fandom.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;
public class Dashboard extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Set the content view to the dashbaord
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setContentView(new StatusViewScroll(this));
}
}
StatusViewScroll.java
package com.commentblock.fandoms;
import android.content.Context;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
public class StatusViewScroll extends RelativeLayout {
public StatusViewScroll(Context c) {
super(c);
ScrollView scrollView = new ScrollView(c);
StatusView statusView = new StatusView(c);
scrollView.addView(statusView);
addView(scrollView);
}
}
StatusView.java
works just fine without the ScrollView
, but when I add it to the ScrollView
, it just breaks. No errors, just a black screen.
Upvotes: 2
Views: 2190
Reputation: 362
I have fixed my issue on my own. The problem lies at StatusView.java, where I needed to override the onMeasure event.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
WindowManager wm = (WindowManager) this.getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
setMeasuredDimension(display.getWidth(), display.getHeight());
}
Upvotes: 3