내 배경 이미지를 변경하려고합니다. 나는 내가 뭔가를 잘못하고 있다고 생각하여 답변을 찾았고 그것을 찾았습니다. hereandroid에서 배경 이미지를 설정할 수 없습니다.
제 코드는 대답과 똑같지 만 작동하지 않습니다. 배경색을 쉽게 바꿀 수 있지만 배경 이미지를 배치하려고하면 실패합니다. 내 jpg (480X800) 리소스는 drawable-hdpi에 있습니다. 나는 해상도를 800x480으로 바꾸려고 노력했다.
지금까지 난 단지 activity_main.xml을 편집하고 일부 리소스를 추가 :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/vertical_lines"
tools:context=".Main" >
<!--
The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc.
-->
<TextView
android:id="@+id/fullscreen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:keepScreenOn="true"
android:text="@string/dummy_content"
android:textColor="#33b5e5"
android:textSize="50sp"
android:textStyle="bold" />
<!--
This FrameLayout insets its children based on system windows using
android:fitsSystemWindows.
-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@drawable/vertical_lines" >
<LinearLayout
android:id="@+id/fullscreen_content_controls"
style="?buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent" >
<Button
android:id="@+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/dummy_button" />
</LinearLayout>
</FrameLayout>
</FrameLayout>
루트 레이아웃에서 android : fillViewport = "true"설정을 시도해 보셨습니까? 또한 자식 뷰없이 루트 레이아웃 만 설정하고 어떤 일이 발생하는지 확인하십시오. 어쩌면 내면의 일부가 문제의 원인이 될 수 있습니다. – dwbrito
감사합니다 fillViewport = "true"시도하고 작동하지 않았다. 나는 아이들을 삭제하려고 노력할 것이다. – Xitcod13
ok 자식을 XML에서 삭제하고 (해당 코드를 삭제하여) 메인에서 오류를 제거 할 때 응용 프로그램이 시작될 때 크래시가 발생합니다. 추적 파일을 열 때 오류가 발생합니다 : 해당 파일 또는 디렉터리가 없습니다. ( – Xitcod13