0
절대 레이아웃을 사용하여 다른 위치에 버튼을 배치하려고합니다.절대 레이아웃에서 레이아웃 기능을 사용하는 버튼 위치를 변경
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bcgrd">
<Button
android:id="@+id/start_challenge"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Start Challenge"
android:textColor= "@color/light_gray"
android:background="@color/background">
</Button>
</AbsoluteLayout>
자바 파일에 다음 코드를 포함 : 나는 다음과 같은 XML 파일을 사용하고
Button start_it = (Button)findViewById(R.id.start_challenge);
start_it.layout(200, 200, 200, 200);
하지만 아무것도 일어나지를합니다 ('200의은, 예를 들어 단지입니다 누군가가 나에게 알려 주시기 바랍니다 수있는. 내가 뭐하는 거지 잘못된
사전에 감사
수 있습니다 당신은 .layout 함수 @kcoppock –
@MuhammadBabar AbsoluteLayout은 더 이상 사용되지 않으며 여러 화면 크기를 지원하지 않습니다. – kcoppock
글쎄, 나는 다른 것을 물어 보았다. 그러나 문제는 내가 사용했던'layout (int left, int top, int right, int bottom)'함수를 사용하고 있다는 것이었다. 프레임 워크는 뷰가 무효화 (새로 고침) 될 때마다이 함수를 호출 할 수 있기 때문에 뷰의 위치/크기가 변경된 경우 ** LayoutParams **를 사용해야합니다. –