View.setAlpha()
(documentation)を使用して、マップの透明度を設定できます。ここでは実施例である:
activity_maps.xml:
<RelativeLayout
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">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="THIS TEXT IS VISIBLE"
android:textSize="24sp"
android:gravity="center"/>
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
MapsActivity.java
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
Marker m = googleMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
m.showInfoWindow();
View v = getSupportFragmentManager().findFragmentById(R.id.map).getView();
v.setAlpha(0.5f); // Change this value to set the desired alpha
}
}
結果はご覧のようなテキストが表示されている(このようになりますの理由地図の透明度):
私はあなたがmapviewでそれを達成できるとは思わない... ViewGroupさえ、Googleはそれに多くのものを追加します。別のマップライブラリを使用するか、UI/UXを再考してみてください。 BTW ...なぜあなたはそれが欲しいでしょうか、達成することができれば本当に悪く見えますか? –
^彼が言ったことは、とにかく悪く見えるだろう。疫病のようなこのような考えを避けてください。代わりに、上のものを透明にしてください(ボタン、アイコンなど...) –
私はそれが悪く見えますが、どのようにそれを達成しますか? Googleがそれを常に不透明にしてくれるのは何ですか?他にどのようなマップライブラリが最適な選択肢ですか? @MarianoZorrilla – Marlon