Android странные огромные размеры меню

#android #menu

#Android #меню

Вопрос:

Привет пытался добавить функцию общего доступа к моему приложению. Тестирование на Moto G.

Но ShareMenu огромен и даже больше, чем экран. Кажется, все в порядке в портретном режиме. Но тормозит в альбомной ориентации.

http://postimg.org/image/ne7zzup43/

В любом случае исходный код https://github.com/pocmo/Instant-Mustache/blob/article-09/src/com/androidzeitgeist/mustache/activity/PhotoActivity.java

казалось, сработало, может быть, потому, что оно привязано к портрету>

Мне пришлось изменить код, чтобы добавить больше пунктов меню, подменю «Поделиться» стало странным.

Вот мой текущий код.

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        uri = getIntent().getData();

        setContentView(R.layout.activity_photo);

        ImageView photoView = (ImageView) findViewById(R.id.photo);
        photoView.setImageURI(uri);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        //getMenuInflater().inflate(R.menu.activity_photo_menu, menu);
    //return super.onCreateOptionsMenu(menu);

         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.activity_photo_menu, menu);
         return true;
    }

    private void sharePhoto() {
        Intent share = new Intent(Intent.ACTION_SEND);
        share.putExtra(Intent.EXTRA_STREAM, uri);
        share.setType(MIME_TYPE);
        startActivity(Intent.createChooser(share, "Share"));
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        switch (item.getItemId()) {
        case R.id.menu_item_share:
            sharePhoto();
            return true;
        case R.id.take_another:
            Toast.makeText(getApplicationContext(), "Go to main Activity", Toast.LENGTH_LONG).show();
            return true;
        }
        return false;
        }

protected void onResume() {
    super.onResume();
    invalidateOptionsMenu(); ///????? Redraw Menu on rotate?????
}
  

Вот мое текущее МЕНЮ XML

   <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >

        <item
            android:id="@ id/menu_item_share"
            android:actionProviderClass="android.widget.ShareActionProvider"
            android:showAsAction="ifRoom"
            android:title="@string/action_share"/>

        <item android:title="@string/take_another" android:id="@ id/take_another"></item>

    </menu>
  

Манифест // (Требования к SDK не установлены)

 <activity android:name="com.mycompany.myapp.photo.PhotoActivity" android:label="@string/app_name"  />
  

Фотоактивность XML

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
     <ImageView
        android:id="@ id/photo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerInside" />
</LinearLayout>