지금 당분간 ActionBar를 만들려고 노력하고 있습니다. 처음에는 이미지로 그릴 것을 결정했지만 (Image 아래의 두 번째 actionBar) 이미지가 전체 화면 너비를 차지하지 않는 일부 장치에서 나타났습니다. 원래 액션 바에 관해서는 나는 내 주요 활동에서 onCreate 방법이 코드를 사용배경 이미지가있는 사용자 정의 ActionBar
final ActionBar actionBar = getActionBar();
@SuppressWarnings("deprecation")
BitmapDrawable background = new BitmapDrawable (BitmapFactory.decodeResource(getResources(), R.drawable.actionbar));
actionBar.setBackgroundDrawable(background);
//actionBar.setIcon(android.R.color.transparent);
actionBar.setDisplayShowTitleEnabled(false);
첫 번째 액션 바는 이미지가 늘어되면서 가벼운 테마를 가지고있다. 어떻게 투명하게 만들 수 있고 ActionBar 높이를 설정하는 방법이 있습니까? 나 또한 스타일로 이것을 시도하고 같은 결과를 가져왔다.
편집 나는 다음과 같이 vinitius 대답을했습니다. result 이미지는 482x104이고, 전화 번호는 480x800입니다. 이것은 일반 이미지로 사용할 때와 동일한 문제입니다. 이미지는 drawable-hdpi 폴더에 있습니다.
EDIT 2 android : scaleType = "fitXY"를 ImageView에 추가하면 이미지 전체가 늘어납니다.
actionbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#3383A8" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="@drawable/actionbar" />
</RelativeLayout>
EDIT 3 나는 그것이 더 큰 장치에서 전체 폭에 맞지 채우기 RelativeLayout의 배경으로 이미지를 추가합니다. 더 큰 너비의 장치에서 이미지로 사용하면 이미지가 늘어납니다. Image
이미 시도한이 http://stackoverflow.com/questions/5861870/actionbar-background-image –
"background.setTileModeX (android.graphics.Shader.TileMode.CLAMP)를 추가했을 때 변경된 것 같습니다. ; " 이제는 ActionBar의 배경에있는 밝은 테마를 제거하고 높이가 변경되는 이미지가 필요합니다. –
그럼 작동 했나요? – vinitius