Commit a9a67ac1 authored by Niklas Fix's avatar Niklas Fix 🎓

fix AkamuLatexView vertical centering with flexbox

parent 18324ac8
......@@ -43,30 +43,32 @@ class LongOptionsAnswerFragment : AnswerFragment(), View.OnClickListener, View.O
val css = """
body { color: white; }
.answer {
.flex-box {
display: flex;
justify-content: center;
text-align: center;
align-items: center;
height: 100%;
}
.answer {
text-align: center;
}
""".trimIndent()
button_questionlongansfragment_answer1.plainText = answer.items[0].text
button_questionlongansfragment_answer1.load("<div class=\"answer\">" + answer.items[0].text + "</div>", css)
button_questionlongansfragment_answer1.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[0].text + "</div></div>", css)
button_questionlongansfragment_answer1.visibility = View.VISIBLE
button_questionlongansfragment_answer2.plainText = answer.items[1].text
button_questionlongansfragment_answer2.load("<div class=\"answer\">" + answer.items[1].text + "</div>", css)
button_questionlongansfragment_answer2.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[1].text + "</div></div>", css)
button_questionlongansfragment_answer2.visibility = View.VISIBLE
if (answer.items.size > 2) {
button_questionlongansfragment_answer3.plainText = answer.items[2].text
button_questionlongansfragment_answer3.load("<div class=\"answer\">" + answer.items[2].text + "</div>", css)
button_questionlongansfragment_answer3.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[2].text + "</div></div>", css)
button_questionlongansfragment_answer3.visibility = View.VISIBLE
button_questionlongansfragment_answer3.setOnTouchListener(this)
if (answer.items.size > 3) {
button_questionlongansfragment_answer4.plainText = answer.items[3].text
button_questionlongansfragment_answer4.load("<div class=\"answer\">" + answer.items[3].text + "</div>", css)
button_questionlongansfragment_answer4.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[3].text + "</div></div>", css)
button_questionlongansfragment_answer4.visibility = View.VISIBLE
button_questionlongansfragment_answer4.setOnTouchListener(this)
}
......
......@@ -42,23 +42,25 @@ class ShortOptionsAnswerFragment : AnswerFragment(), View.OnClickListener, View.
answer = arguments?.getParcelable(Constants.KEY_OPTION_ANSWER)!!
val css = """
body { color: white; }
.answer {
.flex-box {
display: flex;
justify-content: center;
text-align: center;
align-items: center;
height: 100%;
}
.answer {
text-align: center;
}
""".trimIndent()
button_questionshortansfragment_answer1.plainText = answer.items[0].text
button_questionshortansfragment_answer1.load("<div class=\"answer\">" + answer.items[0].text + "</div>", css)
button_questionshortansfragment_answer1.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[0].text + "</div></div>", css)
button_questionshortansfragment_answer2.plainText = answer.items[1].text
button_questionshortansfragment_answer2.load("<div class=\"answer\">" + answer.items[1].text + "</div>", css)
button_questionshortansfragment_answer2.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[1].text + "</div></div>", css)
button_questionshortansfragment_answer3.plainText = answer.items[2].text
button_questionshortansfragment_answer3.load("<div class=\"answer\">" + answer.items[2].text + "</div>", css)
button_questionshortansfragment_answer3.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[2].text + "</div></div>", css)
button_questionshortansfragment_answer4.plainText = answer.items[3].text
button_questionshortansfragment_answer4.load("<div class=\"answer\">" + answer.items[3].text + "</div>", css)
button_questionshortansfragment_answer4.load("<div class=\"flex-box\"><div class=\"answer\">" + answer.items[3].text + "</div></div>", css)
button_questionshortansfragment_answer1.setOnTouchListener(this)
button_questionshortansfragment_answer2.setOnTouchListener(this)
......
......@@ -52,19 +52,22 @@ class SwipeAnswerAdapter(
inner class SwipeItemHolder(itemView: View) {
var answerTextView : AkamuLatexView = itemView.findViewById(R.id.textView_swipe_answer_text)
var css: String = """
body { color: white; }
.answer {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
body { color: white; }
.flex-box {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
.answer {
text-align: center;
}
""".trimIndent()
// AkamuResource.loadCSS(answerTextView, css)
fun bind(text: String) {
answerTextView.plainText = text
answerTextView.load("<div class=\"answer\">$text</div>", css)
answerTextView.load("<div class=\"flex-box\"><div class=\"answer\">$text</div></div>", css)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment