Hi i have a linear layout and i want to show my custom view only horizontal but it just does not work why?i have the xml like that:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:scrollbars="horizontal"
android:id="@+id/ll"
android:background="@drawable/horizon">
but i add custom view on it so maybe there should i set some attributes but i do not know which.
MyView mView = new MyView(this,i);
realViewSwitcher.addView(mView);
myView.java:
public class MyView extends View {
public MyView(Context context, int kolki) {
super(context);
if (kolki == 0){
this.setBackgroundResource(R.drawable.distspeed);
}
if (kolki == 1){
this.setBackgroundResource(R.drawable.hxmdist);
}
}
public void setBackgroundResource (int resid){
super.setBackgroundResource(resid);
}
public void onDraw(Canvas c){
super.onDraw(c);
Paint paint = new Paint();
Path path = new Path();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.TRANSPARENT);
c.drawPaint(paint);
for (int i = 50; i < 100; i++) {
path.moveTo(i, i-1);
path.lineTo(i, i);
}
path.close();
paint.setStrokeWidth(3);
paint.setPathEffect(null);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.STROKE);
c.drawPath(path, paint);
}
}
thanks
i mean somethink like angry birds when you start app it flip to horizontal mode and does not flip back while the game is running, i need exactly the same thing.it should retain in landscape mode while the activity is running