3

私は過去数時間新しいDreamServiceAPIをいじっています、そしてそれはかなり甘いです。ただし、質問が1つあります。

が表示されたら、画面の向きを横向きにロックしたいのDreamServiceですが。の目的はDreamService、多数のワイドスクリーン写真を表示することであり、画面の上下に黒いバーを表示したくありません。

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)Javaコードやandroid:screenOrientation="landscape"マニフェストファイルなど、さまざまなことを試しましたが、どれもうまくいきませんでした。

これは私に不思議に思います:の方向をロックすることは可能DreamServiceですか?

4

3 に答える 3

2

Android開発者チームは、これが現在、ライブ開発者のハングアウト中には不可能であることを確認しました。

グーグルは両方の画面の向きで働きたいと思っDreamServicesているので、それが不可能な理由です。

于 2013-01-27T16:22:57.180 に答える
1

回避策:このライブラリを使用してくださいhttps://github.com/rongi/rotate-layout

build.gradle

 dependencies {
        compile 'rongi.rotate-layout:rotate-layout:2.0.0'
    }

your_daydream_layout.xml

<com.github.rongi.rotate_layout.layout.RotateLayout  
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   app:angle="-90">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <WebView
        android:id="@+id/daydream_webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#2a2e31" />

    <TextView
        android:id="@+id/dream_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-light"
        android:text="..."
            android:textColor="#abc"
            android:textSize="20sp" />
    </RelativeLayout>
</com.github.rongi.rotate_layout.layout.RotateLayout>

そしてところで: あなたの空想を自動回転させることを許可してください..https://code.google.com/p/android/issues/detail ?id = 40226

「これに対する修正が実装されたようです(そして誰も教えてくれませんでした)。残念ながら、正しく機能しません。Nexus6p(6.0.1、ビルド#MHC19Q)で、左端の画面にスワイプすると(Google Now?)、左上のハンバーガーメニューを押し、[設定]を選択して、下部に移動すると、ホーム画面オプションの[回転を許可]が表示されます。これを有効にすると、ホーム画面を次のように回転できるようになります。必要に応じて横向き。Daydreamはその回転を継承し、横向きモードでも表示できます。」-2016年5月18日

于 2016-10-12T12:22:34.103 に答える
0

解決策が見つからなかったのは残念です。レイアウトを設定する直前に、自動回転設定をオフに設定するという、うまくいかない場合もある厄介な回避策を使用する必要がありました。

DreamServiceクラスの場合:

import android.provider.Settings;
<...>

    @Override
public void onAttachedToWindow() {

    Settings.System.putInt(getContentResolver(),
            android.provider.Settings.System.ACCELEROMETER_ROTATION, 0);

    setContentView(R.layout.dream_main);
<...>

マニフェスト:

<uses-permission android:name="android.permission.WRITE_SETTINGS" />
于 2014-11-06T22:40:31.263 に答える