質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Q&A

解決済

1回答

1951閲覧

CoordinatorLayoutの縦横比率指定のやり方が分かりません。

netcafeohashi

総合スコア13

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

0グッド

0クリップ

投稿2016/04/15 05:43

xml

1<?xml version="1.0" encoding="utf-8"?> 2 3<android.support.design.widget.CoordinatorLayout 4 xmlns:android="http://schemas.android.com/apk/res/android" 5 xmlns:app="http://schemas.android.com/apk/res-auto" 6 android:layout_width="match_parent" 7 android:layout_height="match_parent" 8 android:fitsSystemWindows="true"> 9 10 <android.support.design.widget.AppBarLayout 11 android:id="@+id/app_bar_layout" 12 android:layout_width="match_parent" 13 android:layout_height="wrap_content" 14 android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 15 android:fitsSystemWindows="true"> 16 17 <android.support.design.widget.CollapsingToolbarLayout 18 android:id="@+id/collapsing_toolbar" 19 android:layout_width="match_parent" 20 android:layout_height="match_parent" 21 app:layout_scrollFlags="scroll|exitUntilCollapsed" 22 app:contentScrim="?attr/colorPrimary" 23 app:expandedTitleMarginStart="0dp" 24 app:expandedTitleMarginEnd="0dp" 25 26 android:fitsSystemWindows="true"> 27 28 <android.support.v4.view.ViewPager 29 android:id="@+id/view_pager" 30 android:layout_width="match_parent" 31 android:layout_height="280dp" 32 android:adjustViewBounds="true" 33 /> 34 35 <android.support.v7.widget.Toolbar 36 android:id="@+id/toolbar" 37 android:layout_width="match_parent" 38 android:layout_height="?attr/actionBarSize" 39 app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 40 app:layout_collapseMode="pin" /> 41 42 </android.support.design.widget.CollapsingToolbarLayout> 43 44 </android.support.design.widget.AppBarLayout> 45 46 <android.support.v4.widget.NestedScrollView 47 android:id="@+id/scroll" 48 android:layout_width="match_parent" 49 android:layout_height="match_parent" 50 android:clipToPadding="false" 51 app:layout_behavior="@string/appbar_scrolling_view_behavior"> 52 53 54 <android.support.v7.widget.CardView 55 android:layout_width="match_parent" 56 android:layout_height="wrap_content" 57 android:layout_marginTop="8dp" 58 android:layout_marginBottom="20dp" 59 app:cardElevation="6dp" 60 app:cardUseCompatPadding="true"> 61 62 <LinearLayout 63 android:layout_width="match_parent" 64 android:layout_height="wrap_content" 65 android:orientation="vertical"> 66 67 <TextView 68 android:id="@+id/title" 69 android:layout_width="match_parent" 70 android:layout_height="wrap_content" 71 android:layout_marginTop="20dp" 72 android:layout_marginLeft="30dp" 73 android:layout_marginRight="30dp" 74 android:text="test" 75 android:textStyle="bold" 76 android:letterSpacing="0.1" 77 android:textSize="18dp" /> 78 <TextView 79 android:autoLink="web|all" 80 android:layout_width="match_parent" 81 android:layout_height="wrap_content" 82 android:layout_marginTop="15dp" 83 android:layout_marginLeft="30dp" 84 android:layout_marginRight="30dp" 85 android:layout_marginBottom="30dp" 86 android:lineSpacingExtra="5dp" 87 android:id="@+id/notes" 88 /> 89 90 <TextView 91 android:autoLink="web|all" 92 android:layout_width="match_parent" 93 android:layout_height="wrap_content" 94 android:layout_marginTop="15dp" 95 android:layout_marginLeft="30dp" 96 android:layout_marginRight="30dp" 97 android:layout_marginBottom="30dp" 98 android:lineSpacingExtra="5dp" 99 android:id="@+id/url" 100 /> 101 102 </LinearLayout> 103 104 </android.support.v7.widget.CardView> 105 106 107 </android.support.v4.widget.NestedScrollView> 108 <android.support.design.widget.FloatingActionButton 109 android:id="@+id/fab" 110 app:layout_anchor="@id/app_bar_layout" 111 style="@style/fab" 112 app:theme="@style/ThemeOverlay.AppCompat.Light" 113 app:layout_anchorGravity="bottom|right|end" 114 /> 115 116</android.support.design.widget.CoordinatorLayout>

上記XMLのような形で作成しているのですが、
ViewPagerの縦サイズを280dpにすると横幅の大きい端末で崩れてしまうため、
立幅を端末によって調整できるようにしたいです。

なにか方法はありませんでしょうか。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

画面サイズの異なる端末に対応したいということでしょうか?
それならdimens.xmlを端末サイズ毎に用意することで対応できます。
-sw<数値>dp識別子をつけるといいでしょう。

Android DevelopersのAlternativeResourcesを参考にしてください。

投稿2016/04/15 15:35

yona

総合スコア18155

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問