I have a custom view which is intended to represent a coordinate system.
That view is used in one of my xml-files.
Here’s a bit from the xml-file:
...lots of diff views..
<org.test.ScreenProximityView android:layout_below="@+id/screen_proximity_orix_edit"
android:layout_alignParentLeft="true" android:id="@+id/proxTest"
android:layout_marginTop="70dp" android:layout_height="match_parent"
android:layout_width="match_parent">
</org.test.ScreenProximityView>
</RelativeLayout>
The problem is, I want my view to fill the rest of the screen only. When I use match_parent, I get a view that is as big as the screen, but like half gets clipped ‘outside’ the screen.
So how do I resize my view so it fits the remainder of the screen Only?
EDIT: I am going to draw on its canvas like this:
public void onDraw(Canvas canvas) {
canvas.drawLine(0, 0, canvas.getWidth(), 0, mPaint);
canvas.drawLine(0, 0, 0, canvas.getHeight(), mPaint);
canvas.drawLine(0, canvas.getHeight(), canvas.getWidth(), canvas.getHeight(), mPaint);
canvas.drawLine(canvas.getWidth(), canvas.getHeight(), canvas.getWidth(), 0, mPaint);
canvas.drawLine(canvas.getWidth()/2, 0, canvas.getWidth()/2, canvas.getHeight(), mPaint);
canvas.drawLine(0, canvas.getHeight()/2, canvas.getWidth(), canvas.getHeight()/2, mPaint);
}
Which makes most of the stuff stick otuside the viewable screen.
use
for the view, which you want to occupy the remaining space. works with
LinearLayoutas parent view. and rest of the children shouldn’t have any weights.