1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android アプリ実装TIPS、参考サイトまとめ(レイアウト編)

Last updated at Posted at 2017-10-09

文系出身新卒1年目、java、Android未経験者が
Androidアプリを作成していく上で参考になったものまとめですっ! (レイアウト編)

おすすめ記事があれば今後も随時更新予定です!!

<レイアウトTIPS集>

EditTextのデザイン変更

端末によってEditTextのカーソルの色が変わるので、統一したいときはxmlで指定する

EditTextの色変更箇所まとめ

Change the color of the cursor of an EditText in Android across all the sdk

RelativeLayoutにおいて50%配置をやりたい

空のビューを利用することで可能。便利。

RelativeLayout の子の View の width を 50% にする

親ビューの中にある複数のビューの状態を更新するには・・・

こういうときはfindViewWithTag()が便利。
例えば親ビューの中に10子のビューがある時に、10個分findbyしなくても
xmlでタグをつけておいてfor文回せばOK。

findViewWithTag()の使い方

影をつける

API21以上を対象とするならxmlでelevationが使える。
それいがいではxmlを作成して対応する。

How would I get a ListView Item to be elevated?

[Android] アスペクト比が固定のビューを作成する

1:1とか4:3とか、横幅を基準にして高さがその何倍かを決められるカスタムビュークラス。
使い勝手最高。

[Android] アスペクト比が固定のビューを作成する

px から dp へのの変換

コードでサイズ指定するときは単位が px になる。dp に直したいときは以下を参考に。

コード上で高さを数値で設定するときに、デバイス毎に高さが変わってしまう問題

ListViewで、行ごとに違うViewを使う

AdapterでgetItemViewType()をoverrideし、getView()内でcase文を使ってinflateするviewを変える

ListViewで、行ごとに違うViewを使う

リストビュー、リストの中身にあるもの(ボタンとか、画像とか)を触る

リストの中身を触る

ListViewのitem間のスペースについて

<ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="@null"
    android:dividerHeight="10dp" />

AndroidのListViewの区切り線を消す方法と要素ごとのスペースを設定する方法

リストビュー、リストの中身にあるもの(ボタンとか、画像とか)を触る

リストの中身を触る

ダイアログの背景を透明にする

getDialog().getWindow().setBackgroundDrawable(new 
ColorDrawable(Color.TRANSPARENT));

Can't make the custom DialogFragment transparent over the Fragment

RecyclerViewで区切り線(divider)をつける

RecyclerViewで区切り線(divider)をつける

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?