私は以下のイメージのようなレイアウトをデザインしたいと思っています。どのように私はアンドロイドスタジオで透明な背景をすることができますか?
リニアレイアウトアルファを透明にすると、その中のすべてのアイコンも透明になり、完全に正常になります。しかし、私はちょうど透明な背景がすべてのアイテムではない方法をしたい!
私はこのような透明なレイアウトたい:
を私のレイアウトは次のように示しています。ここ
は私のコードです:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:alpha="0.5"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333"
android:padding="10dp"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333"
android:padding="10dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333"
android:padding="10dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
透明なレイアウトでバックグラウンドを作成し、透明部分であなたのアイコンを設定することができます。あなたの結果はあなたを幸せにするでしょう –
私はそれが私がやったことだと思います!自分のコードでどのように修正できるのか教えていただけますか? tnx – Saeid
LinearLayoutの上に#FF000000というように背景に透明な色を付けてください。これにより、レイアウトウィジェットがalphaプロパティの影響を受けないようになります。 –