Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Viewの共通化方法まとめ short ver

konifar
March 12, 2015

Viewの共通化方法まとめ short ver

【第15回】potatotips(iOS/Android開発Tips共有会)
http://connpass.com/event/12140/

でLTした内容です。

konifar

March 12, 2015
Tweet

More Decks by konifar

Other Decks in Programming

Transcript

  1. TUZMFTYNM <TextView style="@style/TextSub" android:layout_width="match_parent" android:layout_height="wrap_content" /> <style name="TextSub"> <item name="android:textSize">@dimen/text_small</item>

    <item name="android:textColor">@color/grey600</item> <item name=“android:gravity">center_vertical</item> <item name="android:maxLines">2</item> </style>
  2. TUZMFTYNM <!-- Extends --> <style name="TextSub.Big"> <item name="android:textSize">@dimen/text_medium</item> </style> <style

    name="TextSub"> <item name="android:textSize">@dimen/text_small</item> <item name="android:textColor">@color/grey600</item> <item name=“android:gravity">center_vertical</item> <item name="android:maxLines">2</item> </style>
  3. JODMVEF <RelativeLayout android:layout_width="match_parent" android:layout_height=“wrap_content”> ! <ImageView … /> ! <RelativeLayout

    android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView … /> <TextView … /> <TextView … /> </RelativeLayout> ! </RelativeLayout>
  4. JODMVEF <RelativeLayout android:layout_width="match_parent" android:layout_height=“wrap_content”> ! <ImageView … /> ! <RelativeLayout

    android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView … /> <TextView … /> <TextView … /> </RelativeLayout> ! </RelativeLayout>
  5. JODMVEF <RelativeLayout android:layout_width="match_parent" android:layout_height=“wrap_content”> ! <ImageView … /> ! <include

    layout=“@layout/part_character_info" /> ! </RelativeLayout> 7JFXͷωετ͕ଟ͘ͳΓ͕ͪͳͷͰɺNFSHFͷ࢖͍ํΛ֮͑ͯ ͓͘ͱΑ͍ɻ 㱺8IBUJTUIFQVSQPTFPG"OESPJETUBHJO9.-MBZPVUT
  6. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  7. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  8. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  9. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  10. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  11. ·ͱΊ EJNFOTYNM DPMPSTYNM ESBXBCMFYNM Կ౓΋ग़ͯ͘Δ ϨΠΞ΢τ͔ JODMVEF $VTUPN7JFX ෳ਺ͷ7JFXͰ ߏ੒͞Ε͍ͯΔ͔

    ϩδοΫؚ͕· ΕΔ͔ ϨΠΞ΢τYNMʹ௚઀هड़ /P :FT /P :FT /P :FT σβΠϯʹ߹Θͤͯ࢖༻ TUZMFTYNM $VTUPN7JFX