I using https://github.com/hakobast/DropdownTextView in version 0.1.1 version 0.3.1 is not suitable for me. I'm wondering if it any chance to change the frame colour when I click DropdownTextView. The second thing is how can I move the DropdownTextView title to the centre? As you can see I have all gravity in centre mode and nothing happens.
My code:
MainActivity.kt
package com.example.myapplication
import android.content.Context
import android.os.Build
import android.os.Bundle
import android.view.*
import android.widget.*
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import com.google.gson.Gson
import hakobastvatsatryan.DropdownTextView
class MainActivity : AppCompatActivity()
{
@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
var zwrotkaString = """{
}"""
var stat:Statistic = Gson().fromJson(zwrotkaString, Statistic::class.java)
val d = findViewById<ListView>(R.id.first_dropdown_text_view_list)
d.adapter = MyCustomAdapter(this@MainActivity, stat);
}
private class MyCustomAdapter(context: Context, stat: Statistic): BaseAdapter()
{
val statS:Statistic
private val mContext: Context
init
{
mContext = context
}
init
{
statS = stat
}
override fun getCount(): Int {
return statS.statisticsForGroups.size;
}
override fun getItem(position: Int): Any
{
return statS.statisticsForGroups[position];
}
override fun getItemId(position: Int): Long
{
return position.toLong();
}
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View
{
val layoutInflater = LayoutInflater.from(mContext);
val rowMain = layoutInflater.inflate(R.layout.rowlistviewstatistic, parent, false)
val statDropDownText = rowMain.findViewById<DropdownTextView>(R.id.dropdowntextrow)
statDropDownText.setTitleText("Title")
statDropDownText.setContentText("Content")
return rowMain
}
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity"
tools:openDrawer="start"
android:layout_gravity="center"
android:gravity="center"
>
<ListView
android:id="@+id/first_dropdown_text_view_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="20sp"
android:scrollbarStyle="insideInset"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewMain"
app:layout_constraintVertical_bias="0.403"
tools:ignore="MissingConstraints"
android:layout_gravity="center"
/>
</LinearLayout>
rowlistviewstatistic.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="qweqdasdasdasdadaq aa fadfeaeef"
/>
<hakobastvatsatryan.DropdownTextView
android:id="@+id/dropdowntextrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:content_text_color="@color/purple_500"
app:arrow_drawable="@drawable/ic_arrow"
app:title_text_color="@color/colorRed"
android:layout_gravity="center"
android:gravity="center"
app:title_text_size="30sp"
app:bg_drawable_expanded="@drawable/answer_drawable"
android:clickable="true"
android:focusable="true"
/>
</LinearLayout>
answer_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/answer_border" />
<corners android:radius="5dp" />
</shape>