-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from TeamPINGLE/feat-custom-edittext
[feat] 커스텀 에딧 텍스트 뷰 구현
- Loading branch information
Showing
7 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/sopt/pingle/presentation/ui/dummy/DummyCustomDEditTextActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sopt.pingle.presentation.ui.dummy | ||
|
||
import android.os.Bundle | ||
import org.sopt.pingle.R | ||
import org.sopt.pingle.databinding.ActivityEditTextCustomTestBinding | ||
import org.sopt.pingle.util.base.BindingActivity | ||
|
||
class DummyCustomDEditTextActivity : BindingActivity<ActivityEditTextCustomTestBinding>(R.layout.activity_edit_text_custom_test) { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/org/sopt/pingle/util/component/PingleEditText.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.sopt.pingle.util.component | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.content.res.TypedArray | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import org.sopt.pingle.R | ||
import org.sopt.pingle.databinding.EditTextPingleBinding | ||
|
||
@SuppressLint("CustomViewStyleable") | ||
class PingleEditText( | ||
context: Context, | ||
attrs: AttributeSet | ||
) : ConstraintLayout(context, attrs) { | ||
private lateinit var binding: EditTextPingleBinding | ||
|
||
init { | ||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.pingleEditText) | ||
try { | ||
initView(typedArray) | ||
} finally { | ||
typedArray.recycle() | ||
} | ||
} | ||
|
||
private fun initView(typedArray: TypedArray) { | ||
binding = EditTextPingleBinding.inflate(LayoutInflater.from(context), this, true) | ||
typedArray.apply { | ||
val title = getString(R.styleable.pingleEditText_title) | ||
binding.tvTitle.text = title | ||
|
||
val hint = getString(R.styleable.pingleEditText_hint) | ||
binding.etEditText.hint = hint | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<size android:width="1dp" /> | ||
<solid android:color="@color/pingle_green" /> | ||
</shape> |
23 changes: 23 additions & 0 deletions
23
app/src/main/res/layout/activity_edit_text_custom_test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<org.sopt.pingle.util.component.PingleEditText | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="@dimen/spacing16" | ||
app:hint="힌트얌" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:title="레이블" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@drawable/shape_border_radius_12" | ||
android:backgroundTint="@color/g_10" | ||
android:paddingHorizontal="@dimen/spacing18" | ||
android:paddingVertical="@dimen/spacing16"> | ||
|
||
<TextView | ||
android:id="@+id/tv_title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textAppearance="@style/TextAppearance.Pingle.Cap.Semi.12" | ||
android:textColor="@color/g_03" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="제목" /> | ||
|
||
<EditText | ||
android:id="@+id/et_edit_text" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:background="@null" | ||
android:imeOptions="actionDone" | ||
android:inputType="text" | ||
android:maxLines="1" | ||
android:textAppearance="@style/TextAppearance.Pingle.Sub.Semi.16" | ||
android:textColor="@color/white" | ||
android:textColorHint="@color/g_07" | ||
android:textCursorDrawable="@drawable/cursor_drawble" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_title" | ||
tools:text="에딧텍스트 내용" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<declare-styleable name="pingleEditText"> | ||
<attr name="title" format="reference|string"/> | ||
<attr name="hint" format="reference|string"/> | ||
</declare-styleable> | ||
</resources> |